#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
using namespace std;
int ask(int x) {
cout << "? " << x << endl;
int ans;
cin >> ans;
return ans;
}
void guess(int x) {
cout << "= " << x << endl;
exit(0);
}
void solve() {
int n;
cin >> n;
if (n <= 64) {
int ptr = 1;
int ptr2 = n;
int lst = -1;
for (int i=1;i<=n;i++) {
if (i%2) {
int c = ask(ptr);
if (!c && lst != -1) {
guess(lst-ptr+1);
return;
}
lst = ptr++;
}else {
int c = ask(ptr2);
if (!c && lst!=-1) {
guess(ptr2-lst+1);
return;
}
lst = ptr2--;
}
}
guess(1);
}
}
signed main() {
ios_base::sync_with_stdio(0),cin.tie(0);
#ifdef Dodi
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
# | 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... |