結果

問題 No.1887 K Consecutive Ks (Easy)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-30 23:00:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 137,516 KB
最終ジャッジ日時 2023-08-09 17:59:31
合計ジャッジ時間 5,398 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,108 KB
testcase_01 AC 72 ms
71,272 KB
testcase_02 AC 421 ms
137,516 KB
testcase_03 AC 73 ms
71,140 KB
testcase_04 AC 72 ms
71,144 KB
testcase_05 AC 71 ms
71,276 KB
testcase_06 AC 71 ms
71,080 KB
testcase_07 AC 74 ms
75,668 KB
testcase_08 AC 79 ms
76,032 KB
testcase_09 AC 82 ms
76,444 KB
testcase_10 AC 86 ms
76,536 KB
testcase_11 AC 137 ms
90,548 KB
testcase_12 AC 102 ms
76,416 KB
testcase_13 AC 399 ms
137,460 KB
testcase_14 AC 412 ms
137,484 KB
testcase_15 AC 404 ms
137,500 KB
testcase_16 AC 339 ms
114,272 KB
testcase_17 AC 271 ms
114,716 KB
testcase_18 AC 411 ms
137,224 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