QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499426#6726. Turn It OffbuzhijingdiWA 0ms3640kbC++14745b2024-07-31 14:07:052024-07-31 14:07:05

Judging History

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

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

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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
10 4
0101011111
3 1
010

output:

-1
-1

result:

wrong answer 1st numbers differ - expected: '3', found: '-1'