QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499426 | #6726. Turn It Off | buzhijingdi | WA | 0ms | 3640kb | C++14 | 745b | 2024-07-31 14:07:05 | 2024-07-31 14:07:05 |
Judging History
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'