結果

問題 No.1011 Infinite Stairs
ユーザー recososo
提出日時 2020-04-12 15:13:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 521 ms / 2,000 ms
コード長 955 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 172,756 KB
実行使用メモリ 427,556 KB
最終ジャッジ日時 2024-07-17 12:05:27
合計ジャッジ時間 4,552 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d,k;cin >> n >> d >> k;
    vector<vector<ll>> dp(n+1,vector<ll>(k+1)),ds(n+1,vector<ll>(k+1));
    dp[0][0]=1;
    for(int i=0;i<=k;i++){
        ds[0][i]=1;
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(j-d-1>=0){
                (dp[i+1][j]+=(ds[i][j-1]-ds[i][j-d-1]+mod)%mod)%=mod;
            }
            else{
                (dp[i+1][j]+=ds[i][j-1])%=mod;
            }
        }
        for(int j=1;j<=k;j++){
            ds[i+1][j]=(ds[i+1][j-1]+dp[i+1][j])%mod;
        }
    }
    cout << dp[n][k] << endl;
}
0