結果

問題 No.2530 Yellow Cards
ユーザー AngrySadEightAngrySadEight
提出日時 2023-10-24 00:10:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 732 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 271,736 KB
最終ジャッジ日時 2023-10-24 00:11:00
合計ジャッジ時間 8,780 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,444 KB
testcase_01 AC 35 ms
53,444 KB
testcase_02 AC 50 ms
66,192 KB
testcase_03 AC 51 ms
66,292 KB
testcase_04 AC 36 ms
53,444 KB
testcase_05 AC 47 ms
66,192 KB
testcase_06 AC 43 ms
59,784 KB
testcase_07 AC 727 ms
271,736 KB
testcase_08 AC 691 ms
271,736 KB
testcase_09 AC 714 ms
271,700 KB
testcase_10 AC 692 ms
271,544 KB
testcase_11 AC 732 ms
271,276 KB
testcase_12 AC 698 ms
271,432 KB
testcase_13 AC 713 ms
271,156 KB
testcase_14 AC 494 ms
202,664 KB
testcase_15 AC 347 ms
156,804 KB
testcase_16 AC 346 ms
157,308 KB
testcase_17 AC 558 ms
224,852 KB
testcase_18 AC 253 ms
133,308 KB
testcase_19 AC 106 ms
89,372 KB
testcase_20 AC 115 ms
88,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
dp = [[0 for _ in range(N + 1)] for _ in range(K + 1)]
dp[0][0] = 1

mod = 998244353

for i in range(K):
    for j in range(N + 1):
        if j > 0:
            dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j] * j) % mod
        if j < N:
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * (N - j)) % mod

div = pow(pow(N, K, mod), mod - 2, mod)
ans = 0
for i in range(N + 1):
    ans = (ans + ((K - i) // 2 + N) * dp[K][i]) % mod
print((ans * div) % mod)
0