結果

問題 No.75 回数の期待値の問題
ユーザー shotoyooshotoyoo
提出日時 2021-06-24 21:05:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 517 bytes
コンパイル時間 1,001 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 76,268 KB
最終ジャッジ日時 2023-09-07 13:26:52
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,296 KB
testcase_01 AC 70 ms
71,376 KB
testcase_02 AC 70 ms
71,328 KB
testcase_03 AC 71 ms
71,368 KB
testcase_04 AC 70 ms
71,296 KB
testcase_05 AC 70 ms
71,400 KB
testcase_06 AC 69 ms
71,368 KB
testcase_07 AC 69 ms
71,436 KB
testcase_08 AC 69 ms
71,376 KB
testcase_09 AC 71 ms
71,288 KB
testcase_10 AC 70 ms
71,360 KB
testcase_11 AC 70 ms
71,536 KB
testcase_12 AC 69 ms
71,324 KB
testcase_13 AC 71 ms
71,476 KB
testcase_14 AC 69 ms
71,436 KB
testcase_15 AC 69 ms
71,372 KB
testcase_16 AC 69 ms
71,340 KB
testcase_17 AC 69 ms
71,424 KB
testcase_18 AC 109 ms
76,268 KB
testcase_19 AC 74 ms
75,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()


sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


k = int(input())
a = [0]*(k+1)
b = [0]*(k+1)
for i in range(k-1,-1,-1):
    aa = bb = 0
    for j in range(1,7):
        if i+j>k:
            aa += 1
        elif i+j<k:
            aa += a[i+j]
            bb += b[i+j]
    a[i] = aa/6
    b[i] = bb/6 + 1
ans = b[0] / (1-a[0])
print(ans)
0