제출 #1134800

#제출 시각아이디문제언어결과실행 시간메모리
1134800lopkusGuess the number (BOI20_guess)C++20
100 / 100
0 ms436 KiB
#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int l = 1, r = n, ans = - 1;
    while(l <= r) {
        int mid = (l + r) / 2;
        cout << "? " << mid;
        cout << endl;
        int x;
        cin >> x;
        if(x == 0) {
            ans = mid;
            break;
        }
        if(x == - 1) {
            l = mid + 1;
        }
        else {
            r = mid - 1;
        }
    }
    cout << "= " << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...