# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1134800 | lopkus | Guess the number (BOI20_guess) | C++20 | 0 ms | 436 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int l = 1, r = n, ans = - 1;
while(l <= r) {
int mid = (l + r) / 2;
cout << "? " << mid;
cout << endl;
int x;
cin >> x;
if(x == 0) {
ans = mid;
break;
}
if(x == - 1) {
l = mid + 1;
}
else {
r = mid - 1;
}
}
cout << "= " << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |