QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499398 | #6727. K-hour Clock | buzhijingdi | WA | 0ms | 3620kb | C++14 | 740b | 2024-07-31 13:52:21 | 2024-07-31 13:52:22 |
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; long long r = x + y;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
input:
4 11 18 5 3 49 4 1 9 1 1 3 10
output:
24 48 1 -1
result:
wrong answer Case #3: k <= x (x = 1, y = 9, z = 1, k = 1)