#include <bits/stdc++.h>
using namespace std;
long long n,maxi,i;
int query (long long x){
int ans;
cout<<"? "<<x<<endl;
cin>>ans;
return ans;
}
void answer (long long x){
cout<<"= "<<x<<endl;
}
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n;
/// incerc sa aleg optim punctul de start
long long st = 1, dr = n, pas = 0, sum = 0, sum2 = n, Left = 0, Right = n;
while (st <= dr){
long long mid = (st+dr)>>1;
pas++;
if (pas % 2){
sum2 -= mid, sum -= mid;
Right = min (Right,sum2);
} else {
sum2 += mid, sum += mid;
Left = max (Left,sum+1);
}
st = mid+1;
}
long long x = Left, c = 0;
query(x);
st = 1, dr = n, pas = 0;
while (st <= dr){
long long mid = (st+dr)>>1;
pas++;
if (pas % 2)
x += mid;
else x -= mid;
int ans = query (x);
if (!ans){
c = mid;
st = mid+1;
} else dr = mid-1;
}
answer(c+1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |