# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
774979 | hgmhc | Guess the number (BOI20_guess) | C++17 | 1 ms | 292 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>
using namespace std;
bool f(int x) {
printf("? %d\n", x);
fflush(stdout);
int q; scanf("%d", &q);
if (q == 0) {
printf("= %d\n", x);
fflush(stdout);
exit(0);
}
else if (q < 0) return true;
else return false;
}
int main() {
int n; scanf("%d", &n);
int a = 1, b = n;
while (a <= b) {
int m = (a+b)/2;
if (f(m)) a = m+1;
else b = m-1;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |