Pagini recente » Cod sursa (job #2243995) | Cod sursa (job #1755311) | Cod sursa (job #1715621) | Diferente pentru problema/rayman intre reviziile 66 si 77 | Cod sursa (job #2753051)
#include <bits/stdc++.h>
using namespace std;
int ask(int x) {
cout << "? " << x << '\n'; cout.flush();
int ans; cin >> ans;
return ans;
}
int main() {
int N, k = 0; cin >> N;
for(int step = (1 << 30); step >= 1; step >>= 1) {
if(step + k <= N && ask(k + step) == 0) {
k += step;
}
}
++k;
cout << "! " << k << '\n';
return 0;
}