#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
typedef long double ld;
const ll inf = 1e9;
const ld eps = 1e-8;
const ll logs = 32;
#include <cmath>
ll c(ll k) {
cout << "? " << k << endl;
ll x;
cin >> x;
return x;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
ll lsz = 0, rsz = n;
ll va = n / 2;
ll left = 0, right = 0;
ll t = 1;
while (va > 1) {
va /= 2;
if (t)
left += va;
else
right += va;
t = 1 - t;
}
ll last;
if (!t)
last = left + 1;
else
last = n - (n / 2) - right;
ll x = c(last);
while (rsz - lsz > 1) {
ll sz = (rsz + lsz) / 2;
ll ind;
if (last + sz <= n)
ind = last + sz;
else
ind = last - sz;
x = c(ind);
if (x == 1) {
rsz = sz;
} else
lsz = sz;
last = ind;
}
cout << "= " << rsz << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |