Problem - 1999G2 - Codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> PII;
#define pb emplace_back
//#define int ll
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define ps push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
void solve();
const int N = 1e6 + 10;
signed main() {
ll t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
ll sb(ll lc,ll rc)
{
ll fx;
ll ans = lc * rc;// rc < x ------>>>>>>>>>
ll ans1 = lc * (rc + 1);//rc >= x && lc < x
ll ans2 = (lc+1) * (rc+1);//lc >= x;
cout << "? " << lc << " " << rc << endl;//***********************服了,这里忘记写了endl
cin >> fx;
if(fx == ans)
{
return -1;
}
else if(fx == ans1) return 0;
else // fx == ans2
return 1;
}
void solve() {
ll l = 2,r = 999;
while(l < r)
{
ll a = l + (r - l)/3, b = r - (r - l)/3;
ll f = sb(a,b);
if(f == -1)// l l
{//>>>>>>>>>>
l = b + 1;
}
else if(f == 0)// lc < x <= r
{//>>>>>>>> <<<<<<<<<<<<
l = a + 1, r = b;
}
else// x <= lc < rc
{
r = a;
}
}
cout << "! " << l << endl;
}