結果

問題 No.1011 Infinite Stairs
ユーザー nagitaosunagitaosu
提出日時 2020-03-20 22:31:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 565 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 288,316 KB
最終ジャッジ日時 2023-09-24 11:00:36
合計ジャッジ時間 5,241 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,332 KB
testcase_01 AC 66 ms
71,364 KB
testcase_02 AC 80 ms
76,400 KB
testcase_03 AC 401 ms
214,528 KB
testcase_04 AC 130 ms
93,008 KB
testcase_05 AC 565 ms
288,316 KB
testcase_06 AC 69 ms
71,528 KB
testcase_07 AC 79 ms
76,248 KB
testcase_08 AC 65 ms
71,368 KB
testcase_09 AC 70 ms
76,188 KB
testcase_10 AC 76 ms
76,064 KB
testcase_11 AC 132 ms
92,972 KB
testcase_12 AC 72 ms
76,212 KB
testcase_13 AC 114 ms
92,652 KB
testcase_14 AC 74 ms
76,120 KB
testcase_15 AC 130 ms
92,832 KB
testcase_16 AC 292 ms
172,916 KB
testcase_17 AC 89 ms
76,528 KB
testcase_18 AC 208 ms
131,848 KB
testcase_19 AC 76 ms
76,188 KB
testcase_20 AC 77 ms
76,328 KB
testcase_21 AC 132 ms
98,652 KB
testcase_22 AC 183 ms
121,664 KB
testcase_23 AC 140 ms
103,132 KB
testcase_24 AC 147 ms
105,212 KB
testcase_25 AC 195 ms
124,360 KB
testcase_26 AC 94 ms
76,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

n, d, k = map(int, input().split())
if n == k:
    print(1)
    exit()
k -= n
d -= 1
dp = [[0] * (k + 1) for _ in range(n)]
for i in range(min(k + 1, d + 1)):
    dp[0][i] = 1
for i in range(n-1):
    for j in range(k+1):
        if j - 1 - d >= 0:
            dp[i + 1][j] = dp[i + 1][j-1] + dp[i][j] - dp[i][j - 1 - d]
            dp[i + 1][j] %= MOD
        else:
            dp[i + 1][j] = dp[i + 1][j-1] + dp[i][j]
            dp[i + 1][j] %= MOD

print(dp[-1][-1])
0