結果

問題 No.246 質問と回答
コンテスト
ユーザー maine_honzuki
提出日時 2021-05-03 16:46:10
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 469 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,935 ms
コンパイル使用メモリ 208,360 KB
実行使用メモリ 29,624 KB
平均クエリ数 30.90
最終ジャッジ日時 2026-06-20 03:54:09
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//https://ncode.syosetu.com/n4830bu/246/
#include <bits/stdc++.h>
using namespace std;

int main() {
    int ok = 0;
    int ng = 1e9 + 10;
    auto check = [](int x) {
        cout << "? " << x << endl;
        int res;
        cin >> res;
        return res;
    };
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << "! " << ok << endl;
}
0