QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#588377 | #9381. 502 Bad Gateway | JTao | WA | 148ms | 3644kb | C++11 | 1.1kb | 2024-09-25 10:09:02 | 2024-09-25 10:09: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 n;
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() {
cin >> n;
int t = sqrt(2 * n);
if (t * t == n) {
prin(t - 1, 2, n, t);
}
else {
int t1, t2;
if (t * t > n) {
t1 = t - 1;
t2 = t;
}
else {
t1 = t;
t2 = t + 1;
}
if ((t1 - 1) / 2 + n / t1 > (t2 - 1) / 2 + n / t2) {
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: 100
Accepted
time: 0ms
memory: 3616kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 148ms
memory: 3644kb
input:
1000000 1 1000000000 1 1 1000000000 1 1000000000 1 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 10000000...
output:
1 1 49997921 1118 1 1 1 1 49997921 1118 1 1 49997921 1118 1 1 1 1 1 1 49997921 1118 1 1 1 1 49997921 1118 1 1 49997921 1118 49997921 1118 1 1 49997921 1118 1 1 1 1 49997921 1118 1 1 49997921 1118 49997921 1118 1 1 49997921 1118 49997921 1118 49997921 1118 49997921 1118 49997921 1118 49997921 1118 1 ...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '49997921 1118'