Cod sursa(job #3344958)
| Utilizator | Data | 7 martie 2026 10:02:57 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin >> N;
long long st = 1, dr = N;
while (st < dr) {
long long mid = (st + dr) / 2;
cout << "? " << mid << endl;
cout.flush();
int ans;
cin >> ans;
if (ans == -1) return 0;
if (ans == 0)
st = mid + 1;
else
dr = mid;
}
cout << "! " << st << endl;
cout.flush();
return 0;
}