QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580387#9381. 502 Bad GatewayttyymmWA 308ms3676kbC++17403b2024-09-21 21:39:202024-09-21 21:39:21

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-21 21:39:21]
  • 评测
  • 测评结果:WA
  • 用时:308ms
  • 内存:3676kb
  • [2024-09-21 21:39:20]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,t;
signed main(){
	ios::sync_with_stdio(0);
	cin>>n;
	while(n--){
		cin>>t;
		int l=floor(sqrt(2*t)),r=ceil(sqrt(2*t)),s;
		long double ans1=(l*(l-1)+2*t)/2/l,ans2=(r*(r-1)+2*t)/2/r;
		ans1>ans2?s=l:s=r;
		int fz=s*(s-1)+2*t,fm=2*s;
		int p=__gcd(fz,fm);
		fz/=p,fm/=p;
		cout<<fz<<" "<<fm<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3676kb

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 308ms
memory: 3676kb

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'