QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#586895 | #9381. 502 Bad Gateway | yeah14 | WA | 359ms | 3736kb | C++17 | 791b | 2024-09-24 16:25:14 | 2024-09-24 16:25:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll __gcd(ll x, ll y) {
if (y == 0)return x;
else return __gcd(y, x % y);
}
void solve() {
ll n;
cin >> n;
ll k = sqrt(2 * n);
ll x1 = k * k - k + 2 * n;
ll x2 = (k + 1) * (k + 1) - (k+1)+2 * n;
ll y1 = 2 * k;
ll y2 = 2 * (k + 1);
if (k * k == 2*n) {
x2 = 0;
y2 = 1;
}
double ans1 = double(x1) / double(y1), ans2 = double(x2) / double(y2);
{
ll k = 0;
if (ans1 > ans2) {
k = __gcd(x1, y1);
x1 /= k;
y1 /= k;
cout << x1 << " " << y1 << endl;
}
else {
k = __gcd(x2, y2);
x2 /= k;
y2 /= k;
cout << x2 << " " << y2 << endl;
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 359ms
memory: 3736kb
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 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 1 1 1 1 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 1 1 1 1 2000006281 44722 1 1 2000006281 44722 2000006281 44722 1 1 2000006281 44722 2000006281 44722 2000006281 44722 20...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000006281 44722'