# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743634 | rahidilbayramli | Guess the number (BOI20_guess) | C++17 | 2 ms | 256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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";
cout << flush;
ll s;
cin >> s;
if(s == -1)
l = mid + 1;
else if(s == 0)
{
cout << "= " << mid;
cout << flush;
return 0;
}
else
r = mid - 1;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |