# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648075 | Kenpar | Guess the number (BOI20_guess) | C++17 | 1 ms | 296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//CSES grind baby
#include "bits/stdc++.h"
using namespace std;
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll MAX = 2e5+1;
int ask(int x){
int temp;
cout<<"? "<<x<<endl;
cin>>temp;
return temp;
}
int bSearch(int l, int r){
if(r >= l){
int mid = (l+r)>>1;
int ans = ask(mid);
if(ans == 0){
return mid;
}else if(ans > 0){
return bSearch(l, mid-1);
}
return bSearch(mid+1, r);
}else{
cout<<1;
}
}
void solve(){
int n;
cin>>n;
int ans = bSearch(1,n);
cout<<"= "<<ans;
}
int main()
{
//cin.tie(NULL);
//ios::sync_with_stdio(NULL);
int t = 1;
//cin >> t;
while(t--){
solve();
cout<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |