結果

問題 No.246 質問と回答
ユーザー TatsuyaOba
提出日時 2015-08-01 14:21:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 159,196 KB
実行使用メモリ 25,220 KB
平均クエリ数 31.90
最終ジャッジ日時 2024-07-16 19:53:23
合計ジャッジ時間 4,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int head_num = 1000000000;
    int tail_num = 1;
    for(int i=0; i<100; i++){
        int num = (head_num + tail_num) / 2;
       cout << "? " << num << endl;
        int tmp;
        cin >> tmp;
        if(tmp == 1){
            if(tail_num == num){
                cout << "! "<< num << endl;
                return 0;
            }
            tail_num = num;
        }else{
            if(head_num == num){
                cout << "! "<<num << endl;
                return 0;
            }
            head_num = num;
        }
    }
    cout <<"! "<< head_num << endl;

    return 0;
}

0