QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584377#9381. 502 Bad Gateway2497201210WA 423ms3620kbC++14721b2024-09-23 13:29:292024-09-23 13:29:29

Judging History

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

  • [2024-09-24 14:55:37]
  • hack成功,自动添加数据
  • (/hack/886)
  • [2024-09-23 13:29:29]
  • 评测
  • 测评结果:WA
  • 用时:423ms
  • 内存:3620kb
  • [2024-09-23 13:29:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N=1e6+10;
const int P=998244353;
int qim(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=(res*a)%P;
		b/=2;
		a=(a*a)%P;
	}
	return res;
}
inline int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
inline void solve(){
	int n;cin>>n;
	int id;double res=1e18;
	for(int i=max(0,(int)sqrt(2*n)-1);i<=min(n,(int)sqrt(2*n)+1);i++){
		long double now=i;
		now=(long double)1.0*n/now+now/2;
		if(now<res){
			res=now;id=i;
		}
	}
	int q=2*n+id*id-id;
	int p=2*id;
	int gg=gcd(q,p);
	q/=gg;
	p/=gg;
	cout<<q<<' '<<p<<endl;
}
signed main(){

	cin.tie(0);cout.tie(0);
	int t;t=1;cin>>t;
	while(t--){
		solve();
	} 
}
 

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 423ms
memory: 3564kb

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'