Submission #868741

#TimeUsernameProblemLanguageResultExecution timeMemory
868741Dec0DeddGuess the number (BOI20_guess)C++14
100 / 100
1 ms600 KiB
#include <bits/stdc++.h>

using namespace std;

int ask(int x) {
    cout<<"? "<<x<<endl;
    int r; cin>>r;
    return r;
}

int main() {
    int n; cin>>n;

    int l=1, r=n;
    while (l <= r) {
        int m=(l+r)/2;

        int k=ask(m);
        if (k == -1) l=m+1;
        else if (k == 1) r=m-1;
        else {
            cout<<"= "<<m<<endl;
            return 0;
        }
    } assert(false);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...