結果

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

ソースコード

diff #

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

int main(){
    int head_num = 100000000;
    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