結果

問題 No.75 回数の期待値の問題
ユーザー convexineqconvexineq
提出日時 2020-12-06 06:02:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 321 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 81,508 KB
実行使用メモリ 59,480 KB
最終ジャッジ日時 2023-10-17 07:00:28
合計ジャッジ時間 2,135 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,248 KB
testcase_01 AC 37 ms
53,248 KB
testcase_02 AC 37 ms
53,248 KB
testcase_03 AC 37 ms
53,252 KB
testcase_04 AC 37 ms
53,248 KB
testcase_05 AC 37 ms
53,248 KB
testcase_06 AC 36 ms
53,248 KB
testcase_07 AC 37 ms
53,252 KB
testcase_08 AC 37 ms
53,252 KB
testcase_09 AC 37 ms
53,252 KB
testcase_10 AC 38 ms
53,252 KB
testcase_11 AC 38 ms
53,252 KB
testcase_12 AC 37 ms
53,252 KB
testcase_13 AC 38 ms
53,252 KB
testcase_14 AC 38 ms
53,252 KB
testcase_15 AC 37 ms
53,252 KB
testcase_16 AC 38 ms
53,252 KB
testcase_17 AC 39 ms
53,252 KB
testcase_18 AC 48 ms
59,480 KB
testcase_19 AC 43 ms
59,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())
dp = [0.0]*(k+1)
prob = [0.0]*(k+1)
prob[0] = 1.0
for i in range(1,k+1):
    r = 0.0
    for j in range(1,7):
        r += dp[i-j] if i-j > 0 else 0        
    dp[i] = 1.0 + r/6
    r = 0.0
    for j in range(1,7):
        r += prob[i-j] if i-j >= 0 else 0        
    prob[i] = r/6
print(dp[k]/prob[k])
0