#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(int pos) {
cout << "! " << pos << endl;
int ret;
cin >> ret;
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int pos=1;
int mul=1;
int l=1,r=n-1;
while (l<=r) {
int m=l+(r-l)/2;
pos+=m*mul;
mul=-mul;
l=m+1;
}
query(pos);
l=1,r=n-1;
int ans=n;
while (l<=r) {
int 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... |