QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580824 | #9381. 502 Bad Gateway | obliviatecqupt | WA | 153ms | 3644kb | C++20 | 682b | 2024-09-22 00:12:52 | 2024-09-22 00:12:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define ll long long
void solve(){
int n;
cin >> n;
int g = sqrt(n);
int a = 1e9, b = 1;
for(int w = max(1ll, g - 10); w <= min(n, g + 10); w++){
int ta = w*w - w + 2*n;
int tb = 2*w;
if(a*tb > tb*b) a = ta, b = tb;
}
int c = __gcd(a, b);
cout << a / c << ' ' << b / c << '\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _;
cin >> _;
while(_--){
solve();
// if(solve()) printf("YES\n");
// else printf("NO\n");
}
// solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 153ms
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 187534487 3954 1 1 1 1 187534487 3954 1 1 187534487 3954 1 1 1 1 1 1 187534487 3954 1 1 1 1 187534487 3954 1 1 187534487 3954 187534487 3954 1 1 187534487 3954 1 1 1 1 187534487 3954 1 1 187534487 3954 187534487 3954 1 1 187534487 3954 187534487 3954 187534487 3954 187534487 3954 187534487 3954 ...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '187534487 3954'