Pagini recente » Diferente pentru problema/sarpe2 intre reviziile 5 si 4 | Cod sursa (job #2325150) | Diferente pentru problema/partitionare intre reviziile 5 si 4 | Diferente pentru problema/gather intre reviziile 13 si 2 | Cod sursa (job #2750791)
#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;
}