Cod sursa(job #2784573)
Utilizator | Data | 16 octombrie 2021 20:33:29 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
using namespace std;
int main(){
int st, dr, mid, ans;
cin>>dr;
st=0;
while(dr-st>1){
mid=(st+dr)/2;
cout<<"? "<<mid<<'\n';
cout.flush();
cin>>ans;
if(ans==0)
st=mid;
else
dr=mid;
}
cout<<"! "<<dr<<'\n';
cout.flush();
return 0;
}