QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581223 | #9381. 502 Bad Gateway | CCF | WA | 202ms | 3808kb | C++14 | 593b | 2024-09-22 10:54:26 | 2024-09-22 10:54:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1.1e6;
typedef long long LL;
typedef long double LD;
#define pii pair<LL,LL>
LD calc(int k,int T){
return (LD)T/k+(LD)k/2-(LD)0.5;
}
void work(){
int T;
scanf("%d",&T);
int o=sqrt(2*T);
int l=max(o-2,1),r=min(o+2,T);
long double x=1e9;
int k=-1;
for(int i=l;i<=r;i++){
LD t=calc(i,T);
if(t<x)t=x,k=i;
}
//cerr<<l<<"%"<<r<<"\n";
LL aa=2LL*T+1LL*k*k-k;
LL bb=2LL*k;
LL g=__gcd(aa,bb);
aa/=g,bb/=g;
cout<<aa<<" "<<bb<<"\n";
}
int main(){
int nn;
scanf("%d",&nn);
while(nn--)work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3808kb
input:
3 1 2 3
output:
1 1 3 2 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 202ms
memory: 3804kb
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 2000051003 44723 1 1 1 1 2000051003 44723 1 1 2000051003 44723 1 1 1 1 1 1 2000051003 44723 1 1 1 1 2000051003 44723 1 1 2000051003 44723 2000051003 44723 1 1 2000051003 44723 1 1 1 1 2000051003 44723 1 1 2000051003 44723 2000051003 44723 1 1 2000051003 44723 2000051003 44723 2000051003 44723 20...
result:
wrong answer 2nd lines differ - expected: '1999961560 44721', found: '2000051003 44723'