Skip to content

Instantly share code, notes, and snippets.

@enzerr

enzerr/Guess.cpp Secret

Created February 7, 2023 18:52
Show Gist options
  • Save enzerr/fc9e56ffbfcae6f4f1a7423d61430c19 to your computer and use it in GitHub Desktop.
Save enzerr/fc9e56ffbfcae6f4f1a7423d61430c19 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
string chute(int x){
cout << x << endl;
string rt; cin >> rt;
return rt;
}
int main(){
int l = 1, r = 1000000, ans = 1;
while(l<=r){
int mid = (l+r)>>1;
if(chute(mid)==">=") l = mid+1, ans = mid;
else r = mid-1;
}
cout << "! " << ans << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment