結果

問題 No.76 回数の期待値で練習
ユーザー 👑 colognecologne
提出日時 2022-01-25 21:55:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 91,856 KB
最終ジャッジ日時 2023-08-22 17:36:23
合計ジャッジ時間 1,070 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,036 KB
testcase_01 AC 143 ms
91,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input(): return sys.stdin.readline().rstrip()


def main():
    T = int(input())
    N = [int(input()) for i in range(T)]

    MAX = max(N)
    DP = [0]*(MAX+1)
    prob = [None, 1/12, 1/6, 1/4, 1/12, 1/4, 1/6]
    for i in range(1, MAX+1):
        DP[i] = 1
        for j in range(1, min(6, i)+1):
            DP[i] += prob[j] * DP[i-j]

    print(*map(lambda x: DP[x], N), sep='\n')


if __name__ == '__main__':
    main()
0