Cod sursa(job #2875513)
Utilizator | Data | 21 martie 2022 19:39:23 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("stirling.in");
ofstream g("stirling.out");
#define f cin
#define g cout
int32_t main()
{
int n, st = 1, dr, p;
cin >> dr;
while (st <= dr)
{
int mid = (st + dr) / 2, ans;
cout << "? " << mid << endl;
cin >> ans;
if (ans)
p = mid, dr = mid - 1;
else
st = mid + 1;
}
cout << "! " << p;
return 0;
}