結果
問題 |
No.1892 Extended Fib Series
|
ユーザー |
![]() |
提出日時 | 2022-04-07 01:23:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 1,434 ms |
コンパイル使用メモリ | 167,880 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 21:29:08 |
合計ジャッジ時間 | 2,456 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 19 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int64_t N, L; cin >> N >> L; const int64_t mod = 1000000007; vector<int64_t> dp(N + 1); dp[0] = 1; int64_t S = 1; int64_t count = 1; for(int64_t i = 1; i <= N; i++) { if(count != L) { dp[i] = S; S += dp[i]; S %= mod; count++; } else { dp[i] = S; S += dp[i]; S -= dp[i - L]; S += mod; S %= mod; } } cout << dp[N] << endl; return 0; }