結果

問題 No.246 質問と回答
ユーザー TokuzooTokuzoo
提出日時 2021-06-18 21:05:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 69,136 KB
実行使用メモリ 25,476 KB
平均クエリ数 30.90
最終ジャッジ日時 2024-07-17 11:31:31
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(){
    int l,r;
    l = 1; r = pow(10,9);

    char c;

    while(1){
        int mid = ceil((double)(l+r)/2);
        cout << '?' << ' ' << mid << endl;
        fflush(stdout);
        cin >> c;
        if(c == '1') l = mid;
        else r = mid-1;

        if(r - l == 1){
            cout << '?' << ' ' << r << endl;
            fflush(stdout);
            cin >> c;
            if(c == 1) cout << '!' << ' ' << r << endl;
            else cout << '!' << ' ' << l << endl;
            return 0;
        }

        if(r == l){
            cout << '!' << ' ' << r << endl;
            return 0;
        }
    }
}
0