QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#581223#9381. 502 Bad GatewayCCFWA 202ms3808kbC++14593b2024-09-22 10:54:262024-09-22 10:54:31

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-22 10:54:31]
  • 评测
  • 测评结果:WA
  • 用时:202ms
  • 内存:3808kb
  • [2024-09-22 10:54:26]
  • 提交

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'