結果

問題 No.1793 実数当てゲーム
ユーザー とりゐとりゐ
提出日時 2021-11-22 21:34:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 94,844 KB
平均クエリ数 2230.56
最終ジャッジ日時 2023-10-13 19:58:33
合計ジャッジ時間 6,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
87,160 KB
testcase_01 AC 104 ms
87,520 KB
testcase_02 AC 275 ms
94,260 KB
testcase_03 AC 273 ms
94,484 KB
testcase_04 AC 272 ms
94,396 KB
testcase_05 AC 266 ms
94,272 KB
testcase_06 AC 268 ms
93,916 KB
testcase_07 AC 256 ms
93,700 KB
testcase_08 AC 254 ms
93,460 KB
testcase_09 AC 250 ms
94,000 KB
testcase_10 AC 251 ms
93,800 KB
testcase_11 AC 265 ms
94,248 KB
testcase_12 AC 258 ms
94,416 KB
testcase_13 AC 260 ms
93,752 KB
testcase_14 AC 285 ms
94,544 KB
testcase_15 AC 262 ms
93,200 KB
testcase_16 AC 279 ms
94,844 KB
testcase_17 AC 273 ms
94,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdout
import math
'''
2^24=16777216=1.67*10^7 なので普通に二分探索をすると不十分
y が小さいなら絶対誤差が 10^-5 以下,大きいなら相対誤差が 10^-5 以下になるようにしてやるといい
最初に 167.77216 で二分探索を行ってみる
これより大きければ対数を取って二分探索をしてみる

---> 最後に調和平均を取る
'''
def solve():
  print1('?',str(167.77216))
  stdout.flush()
  s=input()
  if s=='Yes':
    l,r=167.77216,1222*10**72
    for i in range(23):
      mid=math.sqrt(l*r)
      print1('?','{:.15f}'.format(mid))
      stdout.flush()
      s=input()
      if s=='Yes':
        l=mid
      else:
        r=mid
    mid=2*l*r/(l+r)
    print1('!','{:.15f}'.format(mid))
    stdout.flush()

  elif s=='No':
    l,r=0,167.77216
    for i in range(23):
      mid=(l+r)/2
      print1('?','{:.15f}'.format(mid))
      stdout.flush()
      s=input()
      if s=='Yes':
        l=mid
      else:
        r=mid
    print1('!','{:.15f}'.format((l+r)/2))
    stdout.flush()



# 出力を変更
print1=lambda x,y:print(x,y+'0'*16)

t=int(input())
while t:
  solve()
  t-=1
0