結果

問題 No.1793 実数当てゲーム
ユーザー 👑 NachiaNachia
提出日時 2024-09-16 14:55:11
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 90,628 KB
実行使用メモリ 151,456 KB
平均クエリ数 2152.44
最終ジャッジ日時 2024-09-28 13:44:30
合計ジャッジ時間 5,749 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    cout.precision(15);
    fixed(cout);
    int T; cin >> T;
    double maxval = 1.222e75;
    vector<double> table;
    for(double i=0.0; i<1.0; i+=1.99e-5) table.push_back(i);
    table.push_back(1.0);
    while(table.back() < maxval) table.push_back(table.back() * (1.0 + 1.99e-5));
    table.back() = maxval;
    while(T--){
        int ok = 0;
        int ng = table.size() - 1;
        while(abs(ok - ng) > 1){
            int mid = (ok + ng) / 2;
            cout << "? " << table[mid] << endl;
            string res; cin >> res;
            if(res == "-1") return 0;
            if(res == "Yes") ok = mid; else ng = mid;
        }
        double ans = (table[ok] + table[ng]) / 2;
        cout << "! " << ans << endl;
    }
    return 0;
}
0