結果

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

ソースコード

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