Pagini recente » Cod sursa (job #2801074) | Cod sursa (job #2249446) | Cod sursa (job #2336882) | Cod sursa (job #2800971) | Cod sursa (job #2961942)
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
using ll = long long;
using ci = const int;
using cll = const long long;
using namespace std;
/*******************************/
// INPUT / OUTPUT
/*******************************/
/// GLOBAL DECLARATIONS
int N;
int s, p;
/*******************************/
/// FUNCTIONS
void ReadInput();
void Solution();
void Output();
/*******************************/
///-------------------------------------
inline void ReadInput()
{
cin >> N;
}
///-------------------------------------
bool check(ci &x)
{
short bit;
cout << "? " << x << "\n";
cin >> bit;
cout.flush();
return (bit == 1);
}
///-------------------------------------
inline void Solution()
{
s = 0, p = (1 << (int(log2(N)) + 1));
while (p)
{
if (check(s + p))
s += p;
p >>= 1;
}
}
///-------------------------------------
inline void Output()
{
cout << "! " << s << "\n";
cout.flush();
exit(0);
}
///-------------------------------------
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ReadInput();
Solution();
Output();
return 0;
}