Cod sursa(job #2752281)
Utilizator | Data | 17 mai 2021 15:56:14 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#define lol long long
int main()
{
int n;
scanf("%d", &n);
lol biggest = n;
lol smallest = 1;
while (smallest < biggest)
{
lol mid = (biggest + smallest) / 2;
printf("? %lld\n", mid);
fflush(stdout);
int rez;
scanf("%d", &rez);
if (rez == 0)
smallest = mid + 1;
else
biggest = mid;
}
printf("! %lld\n", smallest);
fflush(stdout);
}