結果

問題 No.1967 Sugoroku Optimization
ユーザー sotanishysotanishy
提出日時 2022-06-03 21:58:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 81,424 KB
実行使用メモリ 75,372 KB
最終ジャッジ日時 2023-10-21 01:51:06
合計ジャッジ時間 3,394 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,268 KB
testcase_01 AC 36 ms
53,268 KB
testcase_02 AC 38 ms
53,268 KB
testcase_03 AC 116 ms
75,360 KB
testcase_04 AC 47 ms
61,632 KB
testcase_05 AC 109 ms
75,372 KB
testcase_06 AC 110 ms
75,372 KB
testcase_07 AC 50 ms
61,668 KB
testcase_08 AC 95 ms
75,364 KB
testcase_09 AC 85 ms
75,372 KB
testcase_10 AC 64 ms
70,252 KB
testcase_11 AC 51 ms
63,716 KB
testcase_12 AC 91 ms
75,372 KB
testcase_13 AC 71 ms
72,300 KB
testcase_14 AC 50 ms
61,668 KB
testcase_15 AC 50 ms
63,716 KB
testcase_16 AC 51 ms
63,716 KB
testcase_17 AC 47 ms
61,332 KB
testcase_18 AC 43 ms
59,284 KB
testcase_19 AC 37 ms
53,268 KB
testcase_20 AC 112 ms
75,368 KB
testcase_21 AC 37 ms
53,268 KB
testcase_22 AC 112 ms
75,360 KB
testcase_23 AC 90 ms
75,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 998244353
N, K = map(int, input().split())
inv = [0] + [pow(i, mod-2, mod) for i in range(1, N+1)]
prob = [0] * (N+1)
prob[0] = 1
for i in range(K):
    nprob = [0] * (N+1)
    for j in range(N):
        nprob[j+1] = (nprob[j] + prob[j]) % mod
    for j in range(1, N+1):
        nprob[j] = nprob[j] * inv[j] % mod
    nprob[0] = 1
    prob = nprob
print(prob[N])
0