結果

問題 No.75 回数の期待値の問題
ユーザー rlangevinrlangevin
提出日時 2023-10-29 12:51:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 383 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 64,220 KB
最終ジャッジ日時 2023-10-29 12:51:41
合計ジャッジ時間 2,384 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,588 KB
testcase_01 AC 36 ms
53,588 KB
testcase_02 AC 39 ms
59,664 KB
testcase_03 AC 41 ms
59,672 KB
testcase_04 AC 40 ms
59,664 KB
testcase_05 AC 40 ms
59,664 KB
testcase_06 AC 40 ms
59,664 KB
testcase_07 AC 41 ms
59,672 KB
testcase_08 AC 43 ms
59,948 KB
testcase_09 AC 42 ms
59,948 KB
testcase_10 AC 42 ms
59,680 KB
testcase_11 AC 43 ms
59,964 KB
testcase_12 AC 42 ms
59,964 KB
testcase_13 AC 44 ms
62,012 KB
testcase_14 AC 43 ms
62,012 KB
testcase_15 AC 45 ms
62,016 KB
testcase_16 AC 46 ms
62,148 KB
testcase_17 AC 47 ms
62,152 KB
testcase_18 AC 49 ms
64,220 KB
testcase_19 AC 49 ms
64,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())


def check(m):
    dp = [1.0] * (K + 2)
    dp[-1] = m
    dp[K] = 0.0
    for i in range(K - 1, -1, -1):
        for j in range(1, 7):
            dp[i] += dp[min(i + j, K + 1)]/6
            
    return dp[0] <= dp[-1]

yes = 1e6
no = 0
for _ in range(60):
    mid = (yes + no)/2
    if check(mid):
        yes = mid
    else:
        no = mid
        
print(yes)
0