結果

問題 No.58 イカサマなサイコロ
ユーザー rpy3cpp
提出日時 2015-07-29 02:14:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 711 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-17 21:35:21
合計ジャッジ時間 1,119 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N = int(input())
K = int(input())

p1 = collections.Counter([i-j for i in range(1, 7) for j in range(1, 7)])
p2 = collections.Counter([i-j for i in range(4, 7) for j in range(1, 7)] * 2)

P = collections.defaultdict(int)
P[0] = 1
for n in range(N - K):
    newP = collections.defaultdict(int)
    for diff, freq in P.items():
        for diff2, freq2 in p1.items():
            newP[diff + diff2] += freq * freq2/36
    P = newP
for k in range(K):
    newP = collections.defaultdict(int)
    for diff, freq in P.items():
        for diff2, freq2 in p2.items():
            newP[diff + diff2] += freq * freq2/36
    P = newP
cump = sum(freq for diff, freq in P.items() if diff > 0)
print(cump)
0