結果

問題 No.1892 Extended Fib Series
ユーザー 👑 Nachia
提出日時 2022-04-05 22:52:02
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 649 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 3,002 ms
コンパイル使用メモリ 110,800 KB
最終ジャッジ日時 2025-01-28 15:20:11
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 19
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
    u32 N, L; cin >> N >> L;
    vector<u32> dp(N+1, 0);
    dp[0] = 1;
    for(u32 i=1; i<=N; i++){
        u64 t = 0;
        for(u32 j=(i>=L)?i-L:0; j<i; j++){
            t += dp[j];
        }
        dp[i] = t % 1000000007;
    }
    cout << dp[N] << '\n';
    return 0;
}

struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0