結果

問題 No.1011 Infinite Stairs
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2020-07-25 15:36:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 958 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 71,632 KB
実行使用メモリ 4,560 KB
最終ジャッジ日時 2023-09-24 11:19:35
合計ジャッジ時間 5,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 15 ms
4,380 KB
testcase_03 AC 624 ms
4,376 KB
testcase_04 AC 106 ms
4,380 KB
testcase_05 AC 958 ms
4,560 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 130 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 79 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 103 ms
4,380 KB
testcase_16 AC 445 ms
4,376 KB
testcase_17 AC 38 ms
4,380 KB
testcase_18 AC 259 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 106 ms
4,380 KB
testcase_22 AC 208 ms
4,376 KB
testcase_23 AC 124 ms
4,376 KB
testcase_24 AC 135 ms
4,380 KB
testcase_25 AC 220 ms
4,380 KB
testcase_26 AC 46 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;
ll mod = 1e9+7;

int main(){
    int n, d, k;
    cin >> n >> d >> k;
    vector<ll> dp(k+1, 0);
    dp[0] = 1;
    while(n--){
        vector<ll> ndp(k+1, 0);
        for(int i = 0; i < k; i++){
            (ndp[i+1] += dp[i]) %= mod;
            if(i+1+d <= k)    (ndp[i+1+d] += (mod-dp[i])) %= mod;
        }
        for(int i = 1; i <= k; i++)   (ndp[i] += ndp[i-1]+mod) %= mod;
        dp = ndp;
    }
    cout << dp[k] << endl;
    return 0;
}
0