This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Dedicated to my love, ivaziva
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = int64_t;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';
const ll maxn = (ll)(1e18);
ll n;
int ask(ll x) {
cout << "? " << x << endl;
int ret; cin >> ret;
return ret;
}
void Solve() {
cin >> n;
ll l = 1, r = n, lst = 1, ans = maxn;
ask(1);
while (l <= r) {
ll mid = (l + r) / 2;
dbg(mid);
int ret = ask(mid + lst);
if (ret) {
r = mid - 1;
ans = mid;
lst = mid + lst;
} else {
l = mid + 1;
}
}
cout << "= " << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.tie(nullptr); cerr.tie(nullptr);
Solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |