Cod sursa(job #2870605)

Utilizator 100pCiornei Stefan 100p Data 12 martie 2022 14:21:18
Problema Cbinteractiv Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.67 kb
#include <bits/stdc++.h>
#define FILES freopen("kfib.in","r",stdin);\
              freopen("kfib.out","w",stdout);
#define ll long long
#define fastio ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
#define MAX 100000
#define pb push_back
#define mp make_pair
#define mod 666013
#define int ll
using namespace std;
int n,rp,ans;
signed main()
{
    fastio
    cin >> n;
    int st = 1, dr = n, ans = 0;
    while(st <= dr)
    {
        int mid = (st + dr) >> 1;
        cout << '?' << mid << '\n';
        cout.flush();
        cin >> rp;
        if(!rp) st = mid + 1;
        else if(rp == 1) dr = mid - 1, ans = mid;
    }
    cout << ans;
}