B:暗水位

补题链接🔗:https://cpc.csgrandeur.cn/csgoj/problemset/problem?pid=1584

二分

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fi first
#define se second
const ll N=5005,mod=92084931,INF=1e18;
void solve(){
ll l=0,r=1e9;
while(l<r){
	ll mid=(l+r)/2;
	cout<<"?"<<" "<<mid<<endl;
	cout.flush();
	ll res;
	cin>>res;
	if(res==1){
		r=mid;
	}else{
		l=mid+1;
	}
}
cout<<"!"<<" "<<l<<endl;
cout.flush();
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll T = 1;
//cin >> T;
while (T--)
solve();
return 0;
}
posted @ 2026-10-13 14:16  yi_one  阅读(8)  评论(0)    收藏  举报