Submission #973832

#TimeUsernameProblemLanguageResultExecution timeMemory
973832kl0989eGuess the number (BOI20_guess)C++17
100 / 100
1 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define vi vector<int> #define pi pair<int, int> #define all(x) (x).begin(),(x).end() int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int l=1,r=n; int res; while (l<=r) { int m=l+(r-l)/2; cout << "? " << m << endl; cin >> res; if (res==0) { cout << "= " << m << endl; return 0; } else if (res==-1) { l=m+1; } else { r=m-1; } } cout << "= " << l << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...