#include using namespace std; int calc(int i, int x) { return x - (i - x); } int main () { int N; cin >> N; int b = N / 2; int a = N / 4; int c = a + b; int p, q, r; cout << "? " << a << endl; cin >> p; cout << "? " << b << endl; cin >> q; cout << "? " << c << endl; cin >> r; p = calc(a, p); q = calc(b, q); r = calc(c, r); if (p == 0) { cout << "! " << a + 1 << " " << N << endl; cin >> N; if (N == -1) { return 139; } return 0; } if (q == 0) { cout << "! " << b + 1 << " " << N << endl; cin >> N; if (N == -1) { return 139; } return 0; } if (r == 0) { cout << "! " << 1 << " " << c << endl; cin >> N; if (N == -1) { return 139; } return 0; } if (p == r) { cout << "! " << a + 1 << " " << c << endl; int x; cin >> x; if (x == -1) { return 139; } return 0; } int mi = 1; int ma = a; if ((p > 0) != (q > 0)) { mi = a; ma = b; while (mi != ma) { int mu = (mi + ma) / 2; cout << "? " << mu << endl; int x; cin >> x; if (x == -1) { //return 139; } x = calc(mu, x); if (x == 0) { ma = mi = mu; } if ((p > 0) == (x > 0)) { mi = mu + 1; } else { ma = mu; } } cout << "! " << mi + 1 << " " << N << endl; int x; cin >> x; if (x == -1) { return 139; } return 0; } if ((q > 0) != (r > 0)) { mi = b; ma = c; while (mi != ma) { int mu = (mi + ma) / 2; cout << "? " << mu << endl; int x; cin >> x; if (x == -1) { //return 139; } x = calc(mu, x); if (x == 0) { ma = mi = mu; } if ((q > 0) == (x > 0)) { mi = mu + 1; } else { ma = mu; } } cout << "! " << 1 << " " << mi << endl; int x; cin >> x; if (x == -1) { return 139; } return 0; } if (abs(r) > abs(p)) { mi = c; ma = N; swap(r, p); } while (ma != mi) { int mu = (ma + mi) / 2; cout << "? " << mu << endl; int x; cin >> x; if (x == -1) { return 139; } x = calc(mu, x); if (x == r) { ma = mi = mu; } else if ((x < r) == (x < p)) { if (mi >= c) { ma = mu; } else { mi = mu + 1; } } else { if (mi >= c) { mi = mu + 1; } else { ma = mu; } } } if (mi >= c) { cout << "! " << a + 1 << ' ' << mi << endl; } else { cout << "! " << mi + 1 << " " << c << endl; } }