QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499428#6727. K-hour ClockbuzhijingdiWA 120ms3668kbC++14745b2024-07-31 14:07:502024-07-31 14:07:51

Judging History

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

  • [2024-07-31 14:07:51]
  • 评测
  • 测评结果:WA
  • 用时:120ms
  • 内存:3668kb
  • [2024-07-31 14:07:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int x, y, z;
int check(int k)
{
	if ((x + (y % k)) % k > z ) {
		return 1;
	}
	else if((x + (y % k)) % k < z ){
		return 2;
	}
	else {
		return 0;
	}
}

void solve()
{
	cin >> x >> y >> z;
	if (x + y < z) {
		cout << -1<<endl;
		return;
	}
	if (x + y == z) {
		cout << x + y + 1<<endl;
		return;
	}
	long long l = x+1; long long r = x + y+1;
	long long mid;
	while (l<r)
	{
		mid = (l + r)/2;
		//cout << "mid " << mid << endl;
		if (check(mid)==1) {
			l = mid + 1;
		}
		else if(check(mid)==2){
			r = mid - 1;
		}
		else {
			break;
		}
	}
	cout << mid<<endl;
}

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
	
	return 0;
}

详细

Test #1:

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

input:

4
11 18 5
3 49 4
1 9 1
1 3 10

output:

24
48
9
-1

result:

ok 4 cases

Test #2:

score: -100
Wrong Answer
time: 120ms
memory: 3668kb

input:

100000
186826504 580942638 34507146
409013320 825277663 642758065
221040339 32805624 253845963
759538401 529610463 314034771
591738614 223935926 591499221
272890462 257036262 529926724
644722795 540369561 79342760
141738127 915104743 658190166
378771709 735410115 474472687
550207480 676282297 233056...

output:

733261995
409013321
253845964
975114094
591738615
529926725
1105749596
141738128
639709136
1203184138
439164015
1057591501
673441983
847965981
-1
20559783
643543523
1229562136
797923155
295517573
488183711
524483170
913981025
616311202
611749282
-1
1345234741
862956524
1053306919
479679110
-1
410033...

result:

wrong answer Case #1: x + y != z (mod k) (x = 186826504, y = 580942638, z = 34507146, k = 733261995)