結果

問題 No.1011 Infinite Stairs
ユーザー betrue12betrue12
提出日時 2020-03-20 21:32:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 470 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 198,496 KB
実行使用メモリ 215,796 KB
最終ジャッジ日時 2023-09-24 10:53:18
合計ジャッジ時間 5,114 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 10 ms
7,308 KB
testcase_03 AC 308 ms
142,600 KB
testcase_04 AC 57 ms
28,172 KB
testcase_05 AC 470 ms
215,796 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 6 ms
5,592 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,752 KB
testcase_11 AC 66 ms
32,780 KB
testcase_12 AC 4 ms
4,396 KB
testcase_13 AC 40 ms
21,160 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 54 ms
26,672 KB
testcase_16 AC 219 ms
101,424 KB
testcase_17 AC 22 ms
12,604 KB
testcase_18 AC 127 ms
59,884 KB
testcase_19 AC 4 ms
4,528 KB
testcase_20 AC 3 ms
4,384 KB
testcase_21 AC 53 ms
26,640 KB
testcase_22 AC 105 ms
49,856 KB
testcase_23 AC 62 ms
30,940 KB
testcase_24 AC 68 ms
33,480 KB
testcase_25 AC 110 ms
52,608 KB
testcase_26 AC 24 ms
13,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, D, K;
    cin >> N >> D >> K;
    static int64_t dp[301][301*301] = {0};
    dp[0][0] = 1;
    for(int i=0; i<N; i++){
        int64_t sum = 0;
        for(int j=1; j<=K; j++){
            add(sum, dp[i][j-1]);
            if(j-D-1 >= 0) add(sum, MOD - dp[i][j-D-1]);
            add(dp[i+1][j], sum);
        }
    }
    cout << dp[N][K] << endl;
    return 0;
}
0