Cod sursa(job #3296766)

Utilizator Latyn76Tinica Alexandru Stefan Latyn76 Data 16 mai 2025 19:05:17
Problema Cbinteractiv Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>
using namespace std;

int n;

int main() {

    cin >> n;
    cout.flush();
    int st = 1, dr = n;
    while (st < dr) {
        int mid = st + (dr - st) / 2;
        cout << "? " << mid << endl;
        _sleep(3000);
        cout.flush();
        int rv = rand() % 2;
        cout << rv << endl;
        _sleep(3000);
        cout.flush();
        if (rv == 1) {
            dr = mid;
        }
        else st = mid + 1;
    }
    cout << "! " << st ;
}