結果
問題 | No.1793 実数当てゲーム |
ユーザー |
|
提出日時 | 2021-11-09 21:12:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 170 ms / 2,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 27,880 KB |
平均クエリ数 | 2230.56 |
最終ジャッジ日時 | 2024-09-28 13:20:20 |
合計ジャッジ時間 | 3,937 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
from math import sqrtfrom sys import stdoutdef 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.10f}"return s[0] + s[1:].rstrip("0").rstrip(".")def middle(left: float, right: float, threshold: float = 1, last=False) -> float:if left < threshold and right > threshold:return thresholdelif left < threshold:return (left + right) / 2elif last:return 2 * right * left / (right + left)else:return sqrt(left * right)def solve():threshold = 167.7717663left = 0.0right = 12.22e74for _ in range(24):mid = middle(left, right, threshold)if query(float2string(mid)):left = midelse:right = midreturn answer(float2string(middle(left, right, threshold, True)))def main():T = int(input())for _ in range(T):solve()if __name__ == "__main__":main()