QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587983 | #9381. 502 Bad Gateway | roufubo | WA | 127ms | 3864kb | C++14 | 570b | 2024-09-24 23:17:04 | 2024-09-24 23:17:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t;
ll gcd(ll a, ll b) {
if (b == 0)return a;
return gcd(b, a % b);
}
void solve() {
scanf("%lld", &t);
if (t == 1)printf("1 1\n");
else if (t == 2)printf("3 2\n");
else if (t == 3)printf("2 1\n");
else {
ll z = (t + 1) / 2 + 1;
ll h = t - z;
ll fz = (1 + z) * z / 2 + h;
ll fm = t - h;
ll gcds = gcd(fz, fm);
fz /= gcds, fm /= gcds;
printf("%lld %lld\n", fz, fm);
}
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3796kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 127ms
memory: 3864kb
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 125000001250000000 500000001 1 1 1 1 125000001250000000 500000001 1 1 125000001250000000 500000001 1 1 1 1 1 1 125000001250000000 500000001 1 1 1 1 125000001250000000 500000001 1 1 125000001250000000 500000001 125000001250000000 500000001 1 1 125000001250000000 500000001 1 1 1 1 1250000012500000...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '125000001250000000 500000001'