Pagini recente » Diferente pentru problema/hidden_points intre reviziile 39 si 63 | Diferente pentru problema/hidden_points intre reviziile 43 si 63 | Cod sursa (job #2384512) | Cod sursa (job #3313767) | Cod sursa (job #2750792)
#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
int guess = 0;
for(int step = (1 << 30); step > 0 ; step >>= 1)
{
int ng = guess + step;
if(ng <= n) {
cout << "? " << ng << endl;
char ans; cin >> ans;
if(ans == '1')
guess = ng;
}
}
cout << "! " << guess << endl;
return 0;
}