結果

問題 No.2530 Yellow Cards
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-11-03 22:47:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,941 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 100,492 KB
最終ジャッジ日時 2023-11-03 22:48:03
合計ジャッジ時間 20,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,628 KB
testcase_01 AC 38 ms
53,628 KB
testcase_02 AC 72 ms
76,660 KB
testcase_03 AC 65 ms
76,676 KB
testcase_04 AC 35 ms
53,672 KB
testcase_05 AC 65 ms
76,696 KB
testcase_06 AC 46 ms
64,560 KB
testcase_07 AC 1,871 ms
100,144 KB
testcase_08 AC 1,853 ms
100,240 KB
testcase_09 AC 1,933 ms
100,140 KB
testcase_10 AC 1,859 ms
100,208 KB
testcase_11 AC 1,894 ms
100,492 KB
testcase_12 AC 1,881 ms
100,280 KB
testcase_13 AC 1,941 ms
100,276 KB
testcase_14 AC 1,378 ms
88,496 KB
testcase_15 AC 884 ms
82,044 KB
testcase_16 AC 917 ms
83,528 KB
testcase_17 AC 1,485 ms
91,564 KB
testcase_18 AC 601 ms
81,136 KB
testcase_19 AC 218 ms
77,028 KB
testcase_20 AC 262 ms
76,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from copy import deepcopy
N, K = map(int, input().split())
mod = 998244353
iv = pow(N, -1, mod)
dp = [0] * (N + 1)
dp[0] = 1
for _ in range(K) :
    dp2 = [0] * (N + 1)
    for i in range(N + 1) :
        p = (i * iv) % mod
        if i :
            dp2[i - 1] += dp[i] * p
            dp2[i - 1] %= mod
        if N - i :
            q = (1 - p + mod) % mod
            dp2[i + 1] += dp[i] * q
            dp2[i + 1] %= mod
    dp = deepcopy(dp2)
ans = N
for i in range(N + 1) :
    r = (K - i) // 2
    ans += dp[i] * r
    ans %= mod
print(ans)
0