Cod sursa(job #3307325)
| Utilizator | Data | 20 august 2025 11:59:33 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
/*
https://infoarena.ro/problema/cbinteractiv
*/
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int st = 1, dr = n;
while (st < dr)
{
int m = (st + dr) / 2;
cout << "? " << m << "\n";
cout.flush();
int raspuns;
cin >> raspuns;
if (raspuns == -1)
{
return 0;
}
if (raspuns == 0)
{
st = m + 1;
}
else
{
dr = m;
}
}
cout << "! " << st << "\n";
cout.flush();
return 0;
}
