제출 #975449

#제출 시각아이디문제언어결과실행 시간메모리
975449Error404Guess the number (BOI20_guess)C++17
100 / 100
1 ms600 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define pi pair<int,int>



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


    int l = 1, r = n;


    while(l<=r){
        int m = (l+r)/2;
        cout << "? "<< m << endl;
        std::cout<<std::endl;
        int ans;
        cin >> ans;
        if(ans==0){
            cout << "= " << m << endl;
            return 0;
        }
        else if(ans==1){
            r = m-1;
        }
        else l = m+1;

    }


    cout << "= "<< l << endl;



}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...