Cod sursa(job #3339579)
| Utilizator | Data | 8 februarie 2026 22:50:54 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
using namespace std;
int n;
int main() {
cin >> n;
int st = 1, dr = n;
while(st <= dr) {
int mid = (st + dr) / 2;
cout << "? " << mid << "\n";
int ans;
cin >> ans;
if(ans == 0) {
st = mid + 1;
} else {
dr = mid - 1;
}
}
cout << "! " << st << "\n";
return 0;
}