QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#671719 | #9381. 502 Bad Gateway | wjh111 | WA | 491ms | 3640kb | C++14 | 521b | 2024-10-24 14:10:55 | 2024-10-24 14:10:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int t,n;
cin>>t;
while (t--){
cin>>n;
int w=sqrt(2*n);
int w1=w+1;
int a[3]={2*n+w*w-w,w*2};
int u=__gcd(a[0],a[1]);
a[1]/=u;
a[0]/=u;
if (w*w==2*n){
cout<<a[0]<<" "<<a[1]<<"\n";
continue;
}
int b[3]={2*n+w1*w1-w1,w1*2};
u=__gcd(b[0],b[1]);
b[1]/=u;
b[0]/=u;
if ((a[0]*b[1])>(b[0]*a[1])){
cout<<a[0]<<" "<<a[1]<<"\n";
}
else{
cout<<b[0]<<" "<<b[1]<<"\n";
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 491ms
memory: 3636kb
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'