結果

問題 No.1793 実数当てゲーム
ユーザー to-omerto-omer
提出日時 2021-12-22 01:11:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 24,448 KB
平均クエリ数 2230.56
最終ジャッジ日時 2023-10-13 20:26:57
合計ジャッジ時間 4,114 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
24,052 KB
testcase_01 AC 44 ms
23,768 KB
testcase_02 AC 152 ms
24,100 KB
testcase_03 AC 151 ms
23,928 KB
testcase_04 AC 151 ms
23,932 KB
testcase_05 AC 151 ms
23,760 KB
testcase_06 AC 152 ms
24,360 KB
testcase_07 AC 150 ms
23,852 KB
testcase_08 AC 152 ms
23,768 KB
testcase_09 AC 151 ms
24,372 KB
testcase_10 AC 151 ms
24,164 KB
testcase_11 AC 150 ms
24,164 KB
testcase_12 AC 152 ms
23,960 KB
testcase_13 AC 156 ms
24,012 KB
testcase_14 AC 154 ms
23,944 KB
testcase_15 AC 152 ms
24,132 KB
testcase_16 AC 156 ms
24,144 KB
testcase_17 AC 152 ms
24,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
from sys import stdout


def query(s: str) -> str:
    print("?", s)
    stdout.flush()
    res = input().rstrip()
    if res == "-1":
        exit(0)
    return res == "Yes"


def answer(s: str):
    print("!", s)
    stdout.flush()


def float2string(f: float) -> str:
    s = f"{f:0.100f}"
    return s[0] + s[1:].rstrip("0").rstrip(".")


def middle(left: float, right: float, last=False) -> float:
    if last:
        return 2 * right * left / (right + left)
    else:
        return sqrt(left * right)


def solve():
    left = 1e-6
    right = 12.22e74
    for _ in range(24):
        mid = middle(left, right)
        if query(float2string(mid)):
            left = mid
        else:
            right = mid
    return answer(float2string(middle(left, right, True)))


def main():
    T = int(input())
    for _ in range(T):
        solve()


if __name__ == "__main__":
    main()
0