結果

問題 No.246 質問と回答
ユーザー face4face4
提出日時 2018-04-30 11:27:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 65,752 KB
実行使用メモリ 25,476 KB
平均クエリ数 30.90
最終ジャッジ日時 2024-07-16 20:16:00
合計ジャッジ時間 3,904 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
    int left = 1, right = 1e9+1, mid, res;
    while(left + 1 < right){
        int mid = (left+right)/2;
        cout << "? " << mid << endl;
        cout << flush;
        cin >> res;
        if(res == 1)        left = mid;
        else if(res == 0)   right = mid;
    }

    cout << "! " << left << endl;
    return 0;
}
0