結果

問題 No.246 質問と回答
ユーザー xuzijian629
提出日時 2018-10-27 01:10:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 194,104 KB
最終ジャッジ日時 2025-01-06 14:47:57
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int l = 1, r = 1e9;
    cout << "? " << r << endl;
    int res;
    cin >> res;
    if (res == 1) {
        cout << "! " << r << endl;
        return 0;
    }
    while (l < r - 1) {
        int m = (l + r) / 2;
        cout << "? " << m << endl;
        cin >> res;
        if (res) {
            l = m;
        } else {
            r = m;
        }
    }
    cout << "! " << l << endl;
}
0