QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749269 | #9381. 502 Bad Gateway | iwew# | WA | 166ms | 3628kb | C++20 | 566b | 2024-11-14 23:16:16 | 2024-11-14 23:16:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T -- ) {
ll n;
cin >> n;
auto check = [&](ll x) -> bool {
return x * x <= x + n;
};
ll l = 1, r = n;
while(l < r) {
ll mid = (l + r + 1) >> 1;
if(check(mid)) l = mid;
else r = mid - 1;
}
ll x = l * (l - 1) / 2 + n, y = l;
cout << x / gcd(x, y) << ' ' << y / gcd(x, y) << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 166ms
memory: 3628kb
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 1499991253 31623 1 1 1 1 1499991253 31623 1 1 1499991253 31623 1 1 1 1 1 1 1499991253 31623 1 1 1 1 1499991253 31623 1 1 1499991253 31623 1499991253 31623 1 1 1499991253 31623 1 1 1 1 1499991253 31623 1 1 1499991253 31623 1499991253 31623 1 1 1499991253 31623 1499991253 31623 1499991253 31623 14...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '1499991253 31623'