#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
bool ask(ll n) {
bool res;
cout << "? " << n << endl;
cin >> res;
return res;
}
int main() {
cin >> n;
ll L = 1, R = n;
ll x = n / 3, dir = 0;
ask(x);
while (L < R) {
ll M = (L + R + 1) / 2;
bool r;
if (dir == 0) {
r = ask(x + M);
x += M;
}
else {
r = ask(x - M);
x -= M;
}
dir = 1 - dir;
if (r)
R = M;
else
L = M + 1;
}
cout << "= " << L << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (3 queries) |
2 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (3 queries) |
2 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (3 queries) |
2 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (3 queries) |
2 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (3 queries) |
2 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |