QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#588397 | #9381. 502 Bad Gateway | JTao | WA | 0ms | 3508kb | C++20 | 1.1kb | 2024-09-25 10:28:01 | 2024-09-25 10:28:03 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e7 + 5;
const int mod = 1e9 + 7;
int gcd(int a, int b) {
int c;
while (b) {
c = a % b;
a = b;
b = c;
}
return a;
}
void prin(int a, int b, int c, int d) {
int t1 = a * d + b * c;
int t2 = b * d;
int t = gcd(t1, t2);
cout << t1 / t << " " << t2 / t << '\n';
}
void solve() {
int n;
cin >> n;
int t = sqrt(2 * n);
if (t * t == n) {
}
else {
int t1, t2;
if (t * t > n) {
t1 = t - 1;
t2 = t;
}
else {
t1 = t;
t2 = t + 1;
}
int tt1 = (t1 - 1) * t1 + 2 * n;
int tt2 = (t2 - 1) * t2 + 2 * n;
if (tt1 * t2 > tt2 * t1) {
prin(t2 - 1, 2, n, t2);
}
else {
prin(t1 - 1, 2, n, t1);
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--)
solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3508kb
input:
3 1 2 3
output:
3 2 2 1
result:
wrong answer 1st lines differ - expected: '1 1', found: '3 2'