結果

問題 No.2530 Yellow Cards
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-11-04 12:16:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 76,240 KB
最終ジャッジ日時 2023-11-04 12:16:40
合計ジャッジ時間 4,112 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,560 KB
testcase_01 AC 36 ms
53,560 KB
testcase_02 AC 125 ms
76,160 KB
testcase_03 AC 67 ms
75,732 KB
testcase_04 AC 37 ms
53,560 KB
testcase_05 AC 125 ms
76,168 KB
testcase_06 AC 36 ms
53,560 KB
testcase_07 AC 214 ms
76,236 KB
testcase_08 AC 214 ms
76,236 KB
testcase_09 AC 214 ms
76,240 KB
testcase_10 AC 214 ms
76,228 KB
testcase_11 AC 214 ms
76,224 KB
testcase_12 AC 214 ms
76,236 KB
testcase_13 AC 213 ms
76,232 KB
testcase_14 AC 200 ms
76,224 KB
testcase_15 AC 166 ms
76,052 KB
testcase_16 AC 133 ms
75,836 KB
testcase_17 AC 199 ms
76,228 KB
testcase_18 AC 83 ms
75,732 KB
testcase_19 AC 53 ms
68,624 KB
testcase_20 AC 109 ms
75,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
mod = 998244353


dp = [0]*k
dp[0] = 1

for i in range(k):

    ndp = [0]*k

    for j in range(k):
        if dp[j] == 0:
            continue

        yellow = i - j*2
        if yellow:
            ndp[j+1] += dp[j] * yellow
            ndp[j+1] %= mod

        if (n-yellow) > 0:
            ndp[j] += dp[j] * (n-yellow)
            ndp[j] %= mod
    
    dp = ndp

ans = 0
for i in range(k):
    ans += (n+i) * dp[i]
    ans %= mod

inv = pow(n,k,mod)
ans *= pow(inv,mod-2,mod)
ans %= mod

print(ans)
0