QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671719#9381. 502 Bad Gatewaywjh111WA 491ms3640kbC++14521b2024-10-24 14:10:552024-10-24 14:10:55

Judging History

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

  • [2024-10-24 14:10:55]
  • 评测
  • 测评结果:WA
  • 用时:491ms
  • 内存:3640kb
  • [2024-10-24 14:10:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int t,n;
	cin>>t;
	while (t--){
		cin>>n;
		int w=sqrt(2*n);
		int w1=w+1;
		int a[3]={2*n+w*w-w,w*2};
		int u=__gcd(a[0],a[1]);
		a[1]/=u;
		a[0]/=u;
		if (w*w==2*n){
			cout<<a[0]<<" "<<a[1]<<"\n";
			continue;
		}
		int b[3]={2*n+w1*w1-w1,w1*2};
		u=__gcd(b[0],b[1]);
		b[1]/=u;
		b[0]/=u;
		if ((a[0]*b[1])>(b[0]*a[1])){
			cout<<a[0]<<" "<<a[1]<<"\n";
		}
		else{
			cout<<b[0]<<" "<<b[1]<<"\n";
		}
	}
}

詳細信息

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 491ms
memory: 3636kb

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'