Submission #1194438

#TimeUsernameProblemLanguageResultExecution timeMemory
1194438kikikicem123Guess the number (BOI20_guess)C++20
100 / 100
0 ms408 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll n, p, l, r, mid, found, x;

int main() {
    //cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n;
    l = 1;
    r = n;
    while (1) {
        if (found) return cout << "= " << p << '\n', int(0);
        mid = l+(r-l)/2;
        cout << "? " << mid << '\n';
        cin >> x;
        if (x == -1) {
            l = mid+1;
        }
        else if (x == 0) {
            found = 1;
            p = mid;
        }
        else {
            r = mid-1;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...