結果
問題 |
No.1892 Extended Fib Series
|
ユーザー |
![]() |
提出日時 | 2022-10-07 09:37:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 384 bytes |
コンパイル時間 | 1,681 ms |
コンパイル使用メモリ | 165,976 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 17:20:47 |
合計ジャッジ時間 | 3,191 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 19 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n,l; cin>>n>>l; const ll mod=1e9+7; ll dp[n+1]; dp[0]=1; dp[1]=1; ll ruiseki=2; for(int i=2;i<=n;i++){ if(i-l>0){ ruiseki=(ruiseki-dp[i-l-1]+mod)%mod; } dp[i]=ruiseki; ruiseki=(ruiseki+dp[i])%mod; } cout<<dp[n]<<endl; }