Cod sursa(job #3243984)
| Utilizator | Data | 22 septembrie 2024 17:52:04 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
int l = 1, r = n;
int result = 0;
while (l <= r) {
int pivot = (l + r) / 2;
cout << "? " << pivot << " " << '\n';
cout.flush();
int nr;
cin >> nr;
if (nr) {
result = max(result, pivot);
r = pivot - 1;
}
else {
l = pivot + 1;
}
}
cout << "! " << l << " " << '\n';
cout.flush();
}