Cod sursa(job #3147276)
Utilizator | Data | 25 august 2023 12:52:29 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int st = 0, dr = n, ok;
while(st != dr)
{
int mid = (st + dr) / 2;
cout << "? " << mid << endl;
cin >> ok;
if(ok == 0)
st = mid + 1;
else
dr = mid;
}
cout << "! " << st << endl;
return 0;
}