結果

問題 No.2791 Beginner Contest
ユーザー t98slidert98slider
提出日時 2024-06-22 18:59:38
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 4,740 ms
コンパイル使用メモリ 262,824 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 18:59:44
合計ジャッジ時間 5,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using mint = atcoder::modint998244353;

int main(){
    int n, k;
    cin >> n >> k;
    vector<mint> dp(n + 1);
    dp[0] = 1, dp[1] = -1;
    for(int i = 0; i < n; i++){
        dp[i + 1] += dp[i];
        if(i + k <= n) dp[i + k] += dp[i];
    }
    cout << accumulate(dp.begin(), dp.end(), mint(0)).val() << '\n';
}
0