QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#499420 | #6727. K-hour Clock | buzhijingdi | WA | 0ms | 3616kb | C++14 | 751b | 2024-07-31 14:03:42 | 2024-07-31 14:03:42 |
Judging History
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)