結果
問題 | No.2791 Beginner Contest |
ユーザー |
|
提出日時 | 2024-06-21 22:56:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 492 bytes |
コンパイル時間 | 2,390 ms |
コンパイル使用メモリ | 195,744 KB |
最終ジャッジ日時 | 2025-02-22 00:02:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;constexpr int MOD=998244353;#define rep(i,n) for(int i=0;i<(int)(n);i++)#define replr(i,l,r) for(int i=(l);i<(int)(r);i++)void ch(ll &a,ll b){a=(a+b)%MOD;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int N,K;cin>>N>>K;vector dp(N+1,0ll);dp[0]=1;ll s=0;for(int i=1;i<=N;i++){if(i-K>=0)ch(s,dp[i-K]);ch(dp[i],s);}ll ans=0;for(ll i:dp)ch(ans,i);cout<<ans<<'\n';}