結果

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

ソースコード

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=0; i<N; i++){
        u32 t = dp[i];
        for(u32 j=i+1; j<=i+L && j<=N; j++){
            dp[j] += t;
            if(dp[j] >= 1000000007) dp[j] -= 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