QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584642#9381. 502 Bad GatewayChief_NingWA 487ms3596kbC++14375b2024-09-23 16:01:062024-09-23 16:01:07

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-23 16:01:07]
  • 评测
  • 测评结果:WA
  • 用时:487ms
  • 内存:3596kb
  • [2024-09-23 16:01:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		int x;
		cin>>x;
		int t1=ceil(sqrt(2*x)),t2=floor(sqrt(2*x));
		int k1=((t1-1)*t1+2*x)*t2,k2=((t2-1)*t2+2*x)*t1;
		int c=0;
		if(k1<k2)c=t1;
		else c=t2;
		int fz=(c-1)*c+2*x,fm=2*c;
		int g=__gcd(fz,fm);
		int ans1=fz/g,ans2=fm/g;
		cout<<ans1<<" "<<ans2<<endl;
	}
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 487ms
memory: 3496kb

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'