QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#753254 | #9381. 502 Bad Gateway | Final_Reunion | WA | 154ms | 3912kb | C++14 | 665b | 2024-11-16 12:01:08 | 2024-11-16 12:01:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,i,j,k,m,z,t,m1,z1;
double a1,a2;
int gcd(int x,int y){
if(x%y==0)return y;
else return gcd(y,x%y);
}
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
if(n==1){
printf("1 1\n");
continue;
}
i=n*2;
j=sqrt(i);
if(j*j==i){
z=j*j+2*n-j;
m=2*j;
k=gcd(m,z);
m/=k;z/=k;
printf("%d %d\n",z,m);
}else{
z=j*j+2*n-j;
m=2*j;
k=gcd(m,z);
m/=k;z/=k;
a1=z/m;
j++;
z1=j*j+2*n-j;
m1=2*j;
k=gcd(m1,z1);
m1/=k;z1/=k;
a2=z1/m1;
if(a1<a2)printf("%d %d\n",z,m);
else printf("%d %d\n",z1,m1);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3912kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 154ms
memory: 3760kb
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 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 1 1 1 1 1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 147522088 -44721 1 1 147522088 -44721 1 1 1 1 147522088 -44721 1 1 147522088 -44721 147522088 -44721 1 1 147522088 -44721 147522088 -44721 147522088 -44721 14...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '147522088 -44721'