結果

問題 No.1793 実数当てゲーム
ユーザー 👑 rin204
提出日時 2023-02-03 14:45:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 946 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 97,952 KB
平均クエリ数 2230.56
最終ジャッジ日時 2024-09-28 13:42:53
合計ジャッジ時間 6,092 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

from pprint import pprint

DEBUG = False

if DEBUG:
    x = ""
    n = 1.41421356237309504880168872420969807856967187537694

    def print(Q, flush):
        # pprint(Q)
        y = float(Q[2:])
        if Q[0] == "!":
            mi = min(abs(n - y), abs(n - y) / abs(n))
            pprint(mi)
            return
        global x
        if y <= n:
            x = "Yes"
        else:
            x = "No"

    def input():
        return x


def judge(Q):
    print(Q, flush=True)
    if Q[0] == "?":
        return input()

T = 1
if not DEBUG:
    T = int(input())

for _ in range(T):
    r = 12.22 * 10 ** 74
    l = 10 ** -6
    for _ in range(24):
        mid = (l * r) ** 0.5
        res = judge(f"? {mid:.12f}")
        # pprint(res)
        if res == "No":
            r = mid
        elif res == "Yes":
            l = mid
        else:
            assert False
            exit()

    ans = (l * r) ** 0.5
    judge(f"! {ans:.12f}")

0