結果

問題 No.1011 Infinite Stairs
ユーザー IlagIlag
提出日時 2020-03-20 22:24:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 1,478 ms
コンパイル使用メモリ 164,652 KB
実行使用メモリ 242,724 KB
最終ジャッジ日時 2023-09-24 11:00:30
合計ジャッジ時間 15,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 459 ms
242,452 KB
testcase_01 AC 462 ms
242,440 KB
testcase_02 AC 466 ms
242,396 KB
testcase_03 AC 463 ms
242,620 KB
testcase_04 AC 462 ms
242,384 KB
testcase_05 AC 462 ms
242,368 KB
testcase_06 AC 461 ms
242,436 KB
testcase_07 AC 461 ms
242,724 KB
testcase_08 AC 461 ms
242,412 KB
testcase_09 AC 463 ms
242,620 KB
testcase_10 AC 464 ms
242,388 KB
testcase_11 AC 461 ms
242,452 KB
testcase_12 AC 464 ms
242,420 KB
testcase_13 AC 465 ms
242,512 KB
testcase_14 AC 463 ms
242,580 KB
testcase_15 AC 460 ms
242,496 KB
testcase_16 AC 461 ms
242,484 KB
testcase_17 AC 461 ms
242,440 KB
testcase_18 AC 463 ms
242,448 KB
testcase_19 AC 460 ms
242,616 KB
testcase_20 AC 461 ms
242,620 KB
testcase_21 AC 462 ms
242,584 KB
testcase_22 AC 463 ms
242,500 KB
testcase_23 AC 462 ms
242,500 KB
testcase_24 AC 463 ms
242,440 KB
testcase_25 AC 463 ms
242,504 KB
testcase_26 AC 461 ms
242,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

const int MOD = 1000000007;
const int MAX_V = 100000;
const int MAX_N = 305;

ll dp[MAX_N + 5][MAX_V + 5];

int main() {
    ll n, d, k;
    cin >> n >> d >> k;
    dp[0][0] = 1;
    for (int i = 0; i <= MAX_N; i++) {
        for (int j = 1; j <= MAX_V; j++) {
            dp[i + 1][j] += dp[i][j - 1];
            if (j - d - 1 >= 0) dp[i + 1][j] -= dp[i][j - d - 1];
            dp[i + 1][j] %= MOD;
            while (dp[i + 1][j] < 0) dp[i + 1][j] += MOD;
        }
        for (int j = 1; j <= MAX_V; j++) {
            dp[i + 1][j] += dp[i + 1][j - 1];
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[n][k] << endl;
}
0