Cod sursa(job #2776374)
Utilizator | Data | 19 septembrie 2021 14:48:27 | |
---|---|---|---|
Problema | Cbinteractiv | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.63 kb |
#include <bits/stdc++.h>
using namespace std;
void usain_bolt()
{
ios::sync_with_stdio(false);
cin.tie(0);
}
int main()
{
//usain_bolt();
int n;
cin >> n;
int left = 1, right = n;
while(left <= right) {
int mid = (left + right) >> 1;
cout << "?" << " " << mid << "\n";
fflush(stdout);
int ans;
cin >> ans;
if(ans == 0) {
left = mid + 1;
}
else if(ans == 1) {
right = mid;
}
else {
return 0;
}
}
cout << "!" << " " << left;
return 0;
}