結果

問題 No.1887 K Consecutive Ks (Easy)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-30 23:00:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 81,896 KB
実行使用メモリ 138,168 KB
最終ジャッジ日時 2024-04-27 12:45:25
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,240 KB
testcase_01 AC 34 ms
53,624 KB
testcase_02 AC 347 ms
137,864 KB
testcase_03 AC 39 ms
52,904 KB
testcase_04 AC 34 ms
53,056 KB
testcase_05 AC 35 ms
52,332 KB
testcase_06 AC 35 ms
52,160 KB
testcase_07 AC 38 ms
57,992 KB
testcase_08 AC 41 ms
60,632 KB
testcase_09 AC 42 ms
63,404 KB
testcase_10 AC 47 ms
65,444 KB
testcase_11 AC 98 ms
89,116 KB
testcase_12 AC 66 ms
70,364 KB
testcase_13 AC 337 ms
137,916 KB
testcase_14 AC 358 ms
137,988 KB
testcase_15 AC 347 ms
137,988 KB
testcase_16 AC 283 ms
114,992 KB
testcase_17 AC 226 ms
114,648 KB
testcase_18 AC 348 ms
138,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
mod = 998244353
dp = [[0]*(m+1) for i in range(n+1)]
dps = [0]*(m+1)
for i in range(2,m+1):
    dp[1][i] = 1
    dps[i] = 1



for i in range(2,n+1):
    s = sum(dps)%mod
    for j in range(2,m+1):
        dp[i][j] = (s - dps[j])%mod
        dps[j] += dp[i][j] - dp[max(0,i-j+1)][j]
        dps[j] %= mod

ans = pow(m,n,mod)-sum(dps)%mod
print(ans%mod)
0