結果

問題 No.425 ジャンケンの必勝法
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-13 00:58:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 1,831 ms
コンパイル使用メモリ 86,372 KB
実行使用メモリ 78,140 KB
最終ジャッジ日時 2023-08-13 18:02:21
合計ジャッジ時間 6,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
77,028 KB
testcase_01 AC 177 ms
77,060 KB
testcase_02 AC 177 ms
77,296 KB
testcase_03 AC 167 ms
77,900 KB
testcase_04 AC 275 ms
77,632 KB
testcase_05 AC 166 ms
77,724 KB
testcase_06 AC 299 ms
77,660 KB
testcase_07 AC 267 ms
77,480 KB
testcase_08 AC 167 ms
77,588 KB
testcase_09 AC 167 ms
77,856 KB
testcase_10 AC 186 ms
77,124 KB
testcase_11 AC 245 ms
77,940 KB
testcase_12 AC 261 ms
77,384 KB
testcase_13 AC 181 ms
77,156 KB
testcase_14 AC 272 ms
77,436 KB
testcase_15 AC 167 ms
76,868 KB
testcase_16 AC 175 ms
76,892 KB
testcase_17 AC 252 ms
78,140 KB
testcase_18 AC 263 ms
78,132 KB
testcase_19 AC 171 ms
77,664 KB
testcase_20 AC 249 ms
77,416 KB
testcase_21 AC 180 ms
76,964 KB
testcase_22 AC 172 ms
77,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, q = map(int, input().split())
win = 1 / 3


def dfs(depth, now, P):
    global win
    if depth >= 21:
        return

    # 必勝法使う
    tmp = now * (P/100) * (1/2)
    win += tmp
    Pnext = max(0, P - q)
    dfs(depth + 1, tmp, Pnext)

    # 使わない
    tmp = now * (1 - P/100) * (1/3)
    win += tmp
    Pnext = min(100, P + q)
    dfs(depth + 1, tmp, Pnext)
    return


dfs(0, 1/3, p)
print(win)
0