Submission #557688

#TimeUsernameProblemLanguageResultExecution timeMemory
557688MherGuess the number (BOI20_guess)C++14
100 / 100
1 ms312 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <cmath> #include <bitset> #include <unordered_map> #include <stack> #include <random> using namespace std; const int N = 300003; const int mod = 1e9 + 7; int query(int x) { cout << "? " << x << endl; int res; cin >> res; return res; } void solve() { int l = 1, r; cin >> r; while (l < r) { int m = (l + r) / 2; int p = query(m); if (p == -1) l = m + 1; else if (p == 1) r = m - 1; else l = r = m; } cout << "= " << l << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...