Submission #743633

#TimeUsernameProblemLanguageResultExecution timeMemory
743633rahidilbayramliGuess the number (BOI20_guess)C++17
100 / 100
1 ms296 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define pb push_back #define all(v) v.begin(), v.end() #define pii pair<int, int> #define pll pair<ll, ll> #define f first #define s second using namespace std; int main() { ll n; cin >> n; ll l = 1, r = n, ans = -1, mid; while(l <= r) { mid = (l + r) / 2; cout << "? " << mid << '\n'; ll s; cin >> s; if(s == -1) l = mid + 1; else if(s == 0) { cout << "= " << mid << '\n'; return 0; } else r = mid - 1; } }

Compilation message (stderr)

Guess.cpp: In function 'int main()':
Guess.cpp:17:22: warning: unused variable 'ans' [-Wunused-variable]
   17 |     ll l = 1, r = n, ans = -1, mid;
      |                      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...