結果
問題 | No.2791 Beginner Contest |
ユーザー |
|
提出日時 | 2024-06-21 21:28:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,012 bytes |
コンパイル時間 | 1,886 ms |
コンパイル使用メモリ | 168,476 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-21 21:28:56 |
合計ジャッジ時間 | 2,462 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for(ll i = 0; i < (n); i++) #define reps(i, l, r) for(ll i = (l); i < (r); i++) #define all(a) (a).begin(), (a).end() #define endl "\n"; const ll INF = 2e18; const ll mod1 = 1000000007; const ll mod2 = 998244353; ll dx[4] = {-1, 1, 0, 0}; ll dy[4] = {0, 0, -1, 1}; void chmin(ll& a, ll b){ if(a > b) a = b; } void chmax(ll& a, ll b){ if(a < b) a = b; } ll gcd(ll a, ll b) {return (b == 0 ? a : gcd(b, a % b));} ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} void solve() { //ofstream cout("text.txt"); ll N, K; cin >> N >> K; vector<ll>dp(N + 1, 0); dp[0] = 1; vector<ll>sum(N + 1, 0); sum[0] = 1; reps(i, 1, N + 1) { if (i - K >= 0) { dp[i] = sum[i - K]; } sum[i] = (sum[i - 1] + dp[i]) % mod2; } cout << sum[N] << endl; } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ll T = 1; //cin >> T; while(T--) solve(); }