Cod sursa(job #3289273)
Utilizator | Data | 26 martie 2025 12:37:19 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
using namespace std;
const int INF = 1e9;
int main()
{
int ans, l, r;
l = 0, r = INF;
while( l < r - 1 ) {
int mij = ( l + r ) / 2;
cout << "? " << mij << " " << endl;
cin >> ans;
if( ans == - 1 )
break;
else if( ans == 0 )
l = mij;
else
r = mij;
}
cout << "! " << r << " " << endl;
return 0;
}