QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585161 | #9381. 502 Bad Gateway | jihan | WA | 171ms | 3604kb | C++14 | 888b | 2024-09-23 19:26:21 | 2024-09-23 19:26:22 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const long long maxn=1e5+5;
const long long MAX=(long long)INT_MAX*(long long)INT_MAX;
void solve(){
int n;
cin >> n;
int c=(int)sqrt(2.0*n);
int c0=c++;
int a,b,temp,a0,b0;
a=c-1;
b=2;
temp=__gcd(a,b);
a/=temp;
b/=temp;
a=a*(c)+n*2;
b*=c;
temp=__gcd(a,b);
a/=temp;
b/=temp;
a0=c0-1;
b0=2;
temp=__gcd(a0,b0);
a0/=temp;
b0/=temp;
a0=a0*(c0)+n*2;
b0*=c0;
temp=__gcd(a0,b0);
a0/=temp;
b0/=temp;
if(1.0*a/b>1.0*a0/b0){
cout << a0 << ' ' << b0 << '\n';
}
else{
cout << a << ' ' << b << '\n';
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
cin >> t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 171ms
memory: 3556kb
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'