Submission #387739

#TimeUsernameProblemLanguageResultExecution timeMemory
387739KrisjanisPGuess the number (BOI20_guess)C++14
100 / 100
1 ms288 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll query(ll X){ cout<<"? "<<X<<endl; ll res; cin>>res; return res; } int main(){ ll N; cin>>N; ll l=1, r=N; bool found = false; while(found == false){ ll m = (l+r)/2; ll q = query(m); if(q==1){ r=m-1; } else if(q==0){ found = true; break; } else{ l=m+1; } } cout<<"= "<<(l+r)/2<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...