結果

問題 No.75 回数の期待値の問題
ユーザー ayaoniayaoni
提出日時 2021-08-30 23:37:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 1,169 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 76,252 KB
最終ジャッジ日時 2023-08-15 23:39:20
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,404 KB
testcase_01 AC 72 ms
71,732 KB
testcase_02 AC 72 ms
71,332 KB
testcase_03 AC 71 ms
71,724 KB
testcase_04 AC 70 ms
71,728 KB
testcase_05 AC 70 ms
71,472 KB
testcase_06 AC 69 ms
71,556 KB
testcase_07 AC 68 ms
71,420 KB
testcase_08 AC 70 ms
71,384 KB
testcase_09 AC 70 ms
71,188 KB
testcase_10 AC 69 ms
71,192 KB
testcase_11 AC 69 ms
71,300 KB
testcase_12 AC 71 ms
71,512 KB
testcase_13 AC 70 ms
71,408 KB
testcase_14 AC 71 ms
71,628 KB
testcase_15 AC 71 ms
71,188 KB
testcase_16 AC 70 ms
71,540 KB
testcase_17 AC 74 ms
71,560 KB
testcase_18 AC 76 ms
76,252 KB
testcase_19 AC 76 ms
76,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


K = I()
E = [(0,0)]*(K+6)
# E[i] = サイコロの目の合計がiのときのサイコロの振る回数の期待値
# (a,b) ⇔ a+b*E[0]
for i in range(K+1,K+6):
    E[i] = (0,1)

for i in range(K-1,-1,-1):
    a,b = 0,0
    for j in range(i+1,i+7):
        c,d = E[j]
        a += c
        b += d
    E[i] = 1+a/6,b/6

a,b = E[0]
ans = a/(1-b)
print(ans)
0