QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499420#6727. K-hour ClockbuzhijingdiWA 0ms3616kbC++14751b2024-07-31 14:03:422024-07-31 14:03:42

Judging History

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

  • [2024-07-31 14:03:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-07-31 14:03:42]
  • 提交

answer

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

int x, y, z;
int check(int k)
{
	if ((x + (y % k)) % k > z&&k>x) {
		return 1;
	}
	else if((x + (y % k)) % k < z&&k>x){
		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 << l<<endl;
}

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

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

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

output:

24
48
7
-1

result:

wrong answer Case #3: x + y != z (mod k) (x = 1, y = 9, z = 1, k = 7)