#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
#define pow poww
const ll M=1e5+10;
const ll inf=2e18;
const ll mod=1e9+7;
ll pow(ll x,ll y){
ll res=1;
x%=mod;
while(y>0){
if((y&1))
res*=x,res%=mod;
x*=x,x%=mod;
y=(y>>1);
}
return res;
}
ll n,ans;
bool ask(ll x){
cout<<"? "<<x<<endl;
bool c;
cin>>c;
return c;
}
void ret(ll x){
cout<<"= "<<x<<endl;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
ll TC=1;
//cin>>TC;
while(TC--){
cin>>n;
ll l=1,r=n-1,mid;
while(l<=r){
mid=((l+r)>>1);
ask(1);
if(!ask(mid+1))
l=mid+1;
else
r=mid-1,ans=mid;
}
ret(mid);
}
return 0;
}
/*
*/
Compilation message
Colors.cpp: In function 'int main()':
Colors.cpp:50:8: warning: 'mid' may be used uninitialized in this function [-Wmaybe-uninitialized]
50 | ret(mid);
| ~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Hair color 1 was used multiple times |
2 |
Halted |
0 ms |
0 KB |
- |