QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#592391#9381. 502 Bad Gatewayparamecium-4WA 672ms3644kbC++141.2kb2024-09-26 22:13:542024-09-26 22:13:55

Judging History

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

  • [2024-09-26 22:13:55]
  • 评测
  • 测评结果:WA
  • 用时:672ms
  • 内存:3644kb
  • [2024-09-26 22:13:54]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int t;
int lmid,rmid;
double check(int k)
{
	return (k + 1) / 2.0 + t * 1.0 / k - 1; 
}
int main()
{
	int T;  cin>>T;
	while(T--)
	{
		cin>>t;
		int l = 1, r = t;
		int id = 1;
		double lans,rans,ans = check(1);
		//cout<<ans<<endl;
		while(l <= r)
		{
			lmid = l + (r - l + 1) / 3;
			rmid = r - (r - l + 1) / 3;
			//cout<<lmid<<" "<<rmid<<endl;
			lans = check(lmid);
			rans = check(rmid);
			if(ans > lans) id = lmid, ans = lans;
			if(ans > rans) id = rmid, ans = rans;
//			cout<<lmid<<' '<<rmid<<' '<<check(lmid)<<' '<<check(rmid)<<endl;
//			cout<<lans<<' '<<rans<<' '<<l<<' '<<r<<" "<<id<<endl; 
			if(lans <= rans) r = rmid - 1;
			else l = lmid + 1;
			
		}
		for (int i = min(lmid,rmid) - 5;i <= max(lmid,rmid) + 5;i++)
		{
			if(i < 1 || i > t) continue;
			lans = check(i);
			if(ans > lans) id = i, ans = lans;
		}
		//cout<<ans<<" "<<id<<endl;
		int x = id * (id - 1) + 2 * t;
		int y = 2 * id;
		//cout<<id<<' '<<x<<' '<<y<<endl;
		//cout<<x<<' '<<y<<endl;
		int gg = __gcd(x,y);
		x /= gg; y /= gg;
		cout<<x<<' '<<y<<endl;
	}

 	return 0;
}

详细

Test #1:

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

input:

3
1
2
3

output:

1 1
3 2
2 1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 672ms
memory: 3644kb

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'