結果

問題 No.1892 Extended Fib Series
ユーザー zezero
提出日時 2022-04-05 23:13:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 2,711 ms
コンパイル使用メモリ 158,092 KB
最終ジャッジ日時 2025-01-28 15:21:19
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 19
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
using mint = modint1000000007;
mint dp[100001];
int main(){
  int n,l;
  cin >> n >> l;
  dp[0] = 1;
  for (int i = 0; i < n;i++){
    if (i > 0) dp[i] += dp[i-1]; 
    dp[i+1] += dp[i];
    if (i-l >= 0) dp[i+1] -= dp[i-l];
  }
  //for (int i = 0; i <= n;i++){
  //  cout << dp[i].val() << " ";
  //}
  //cout << endl;
  cout << dp[n].val() << endl;

  return 0;
}
0