#include <iostream>
using namespace std;
#define int long long
int n, at;
bool qry(int x) {
if (at <= n / 2) at += x;
else at -= x;
cout << "? " << at << endl;
bool ans; cin >> ans;
return ans;
}
int32_t main() {
cin >> n;
bool added = true;
at = 1;
int test = 0;
for (int i = 62; i >= 0; --i) {
int chg = test + (1LL << i);
if (chg >= n) continue;
if (!added) at += 1LL << i;
added = !added, test = chg;
}
cout << "? " << at << endl;
int tmp; cin >> tmp;
int sum = 0;
for (int i = 62; i >= 0; --i) {
int chg = sum + (1LL << i);
if (chg >= n) continue;
if (!qry(chg)) sum = chg;
}
cout << "= " << sum + 1 << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (4 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 (4 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 (4 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 (4 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 (4 queries) |
2 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |