Cod sursa(job #2759977)
Utilizator | Data | 21 iunie 2021 19:19:09 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 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;
return 0;
}