Submission #728956

#TimeUsernameProblemLanguageResultExecution timeMemory
728956Erfan1386YGuess the number (BOI20_guess)C++14
100 / 100
1 ms292 KiB
#include <bits/stdc++.h>
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);
#define kill(x) {cout << x << '\n'; return ;}
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ll long long
#define ppb pop_back
#define MP make_pair
#define vec vector
#define endl '\n'
#define F first
#define S second
const ll inf = 1e14, mod = 1e9 + 7;

using namespace std;
const int N = 1e9 + 10;

int main () {
	// fast_io;
    int n;
    cin >> n;
    int l = 1, r = n;
    while (1) {
        ll mid = (r + l) / 2;
        cout << "? " << mid << '\n';
        int x;
        cin >> x;
        if (x == -1) l = mid + 1;
        if (x == 1) r = mid - 1;
        if (x == 0) {
            cout << "= " << mid << '\n';
            return 0;
        }
    }
	return 0;
//cheak MAXN Bruh 0-0
}

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