#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
bool query(ll pos) {
cout << "! " << pos << endl;
int ret;
cin >> ret;
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
ll pos=1;
ll mul=1;
ll l=1,r=n-1;
ll mn=n-1;
while (l<=r) {
ll m=l+(r-l)/2;
pos+=m*mul;
mul=-mul;
l=m+1;
mn=min(mn,pos);
}
pos=2-mn;
mul=1;
query(pos);
l=1,r=n-1;
ll ans=n;
while (l<=r) {
ll m=l+(r-l)/2;
pos+=m*mul;
mul=-mul;
if (query(pos)) {
ans=m;
r=m-1;
}
else {
l=m+1;
}
}
cout << "= " << ans << endl;
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... |