QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585174 | #9381. 502 Bad Gateway | jihan | WA | 197ms | 3696kb | C++14 | 881b | 2024-09-23 19:30:47 | 2024-09-23 19:30:47 |
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=sqrt(2*n);
int c0=c+1;
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: 1ms
memory: 3692kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 197ms
memory: 3696kb
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'