結果

問題 No.2530 Yellow Cards
ユーザー shobonvipshobonvip
提出日時 2023-11-02 04:26:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 858 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 271,504 KB
最終ジャッジ日時 2023-11-02 04:26:34
合計ジャッジ時間 10,559 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,584 KB
testcase_01 AC 37 ms
53,584 KB
testcase_02 AC 45 ms
62,272 KB
testcase_03 AC 54 ms
64,500 KB
testcase_04 AC 37 ms
53,584 KB
testcase_05 AC 52 ms
62,272 KB
testcase_06 AC 43 ms
59,944 KB
testcase_07 AC 844 ms
271,500 KB
testcase_08 AC 858 ms
271,504 KB
testcase_09 AC 858 ms
271,464 KB
testcase_10 AC 833 ms
271,300 KB
testcase_11 AC 857 ms
271,032 KB
testcase_12 AC 858 ms
271,192 KB
testcase_13 AC 854 ms
270,916 KB
testcase_14 AC 595 ms
206,780 KB
testcase_15 AC 405 ms
160,720 KB
testcase_16 AC 426 ms
160,784 KB
testcase_17 AC 650 ms
224,996 KB
testcase_18 AC 311 ms
133,508 KB
testcase_19 AC 116 ms
89,460 KB
testcase_20 AC 132 ms
91,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n, k = map(int,input().split())
ans = n
ninv = pow(n, mod-2, mod)

dp = [[0] * (n+1) for i in range(k+1)]
dp[0][0] = 1
for i in range(k):
	for j in range(n+1):
		if j > 0:
			dp[i+1][j-1] += j * ninv % mod * dp[i][j]
			dp[i+1][j-1] %= mod
			ans += j * ninv % mod * dp[i][j] % mod
		if j < n:
			dp[i+1][j+1] += (n-j) * ninv % mod * dp[i][j]
			dp[i+1][j+1] %= mod

ans %= mod
print(ans)
0