Cod sursa(job #3344994)
| Utilizator | Data | 7 martie 2026 12:00:15 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <iostream>
using namespace std;
int main()
{
int n, st, dr;
cin >> n;
st = 1;
dr = n;
while (st < dr)
{
int x = (st + dr) / 2;
cout << "? " << x << endl;
int raspuns;
cin >> raspuns;
if (raspuns == -1)
{
return 0;
}
if (raspuns == 0)
{
st = x + 1;
}
else
{
dr = x;
}
}
cout << "! " << st << endl;
return 0;
}
