Cod sursa(job #3296752)
Utilizator | Data | 16 mai 2025 14:38:00 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.54 kb |
#include <iostream>
using namespace std;
const int A = 1;
int main()
{
int n;
cin >> n;
int st = A, dr = n, rez = -1;
while (st < dr)
{
int m = (st + dr) / 2;
cout << "? " << m << endl;
int raspuns;
cin >> raspuns;
if (raspuns == -1)
{
return 0;
}
if (raspuns == 0)
{
st = m + 1;
}
else
{
dr = m;
}
}
cout << "! " << st << endl;
return 0;
}