Cod sursa(job #2759978)
Utilizator | Data | 21 iunie 2021 19:20:43 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
using namespace std;
int main()
{
int n,st,dr,mid;
cin>>n;
st=1,dr=n;
while(st!=dr)
{
bool lower;
mid=(st+dr)/2;
cout<<"? "<<mid<<'\n';
cout.flush();
cin>>lower;
if(lower) dr=mid;
else st=mid+1;
}
cout<<"! "<<st<<'\n';
return 0;
}