Cod sursa(job #3344993)
| Utilizator | Data | 7 martie 2026 11:57:38 | |
|---|---|---|---|
| Problema | Cbinteractiv | Scor | 0 |
| 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 k = (st + dr) / 2;
cout << "? " << k << endl;
int raspuns;
cin >> raspuns;
if (raspuns == -1)
{
return 0;
}
if (raspuns == 0)
{
dr = k - 1;
}
else
{
st = k;
}
}
cout << "! " << st << endl;
return 0;
}
