結果

問題 No.1011 Infinite Stairs
ユーザー d9etd9et
提出日時 2020-03-20 22:10:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 391 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 77,776 KB
最終ジャッジ日時 2023-09-24 10:58:08
合計ジャッジ時間 4,969 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,312 KB
testcase_01 AC 73 ms
71,196 KB
testcase_02 AC 90 ms
76,348 KB
testcase_03 AC 286 ms
77,288 KB
testcase_04 AC 120 ms
76,404 KB
testcase_05 AC 391 ms
77,776 KB
testcase_06 AC 74 ms
71,212 KB
testcase_07 AC 87 ms
76,120 KB
testcase_08 AC 73 ms
71,124 KB
testcase_09 AC 78 ms
76,028 KB
testcase_10 AC 83 ms
75,920 KB
testcase_11 AC 125 ms
76,408 KB
testcase_12 AC 84 ms
76,108 KB
testcase_13 AC 106 ms
76,212 KB
testcase_14 AC 78 ms
76,096 KB
testcase_15 AC 115 ms
76,428 KB
testcase_16 AC 222 ms
77,104 KB
testcase_17 AC 96 ms
76,300 KB
testcase_18 AC 162 ms
76,792 KB
testcase_19 AC 84 ms
76,208 KB
testcase_20 AC 80 ms
76,108 KB
testcase_21 AC 116 ms
76,436 KB
testcase_22 AC 150 ms
76,712 KB
testcase_23 AC 121 ms
76,720 KB
testcase_24 AC 124 ms
76,400 KB
testcase_25 AC 153 ms
76,808 KB
testcase_26 AC 96 ms
76,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
n,d,k = map(int,input().split())
mod = 10**9+7
dp = [0 for i in range(k+1)]
dp[0] = 1
acc = [0]*(k+1)
for i in range(1,n+1):
  acc[0] = dp[0]
  for j in range(1,k+1):
    acc[j] = (acc[j-1]+dp[j])%mod
  dp[0] = 0
  for j in range(1,k+1):
    if j <= d:
      dp[j] = acc[j-1]
    else:
      dp[j] = (acc[j-1]-acc[j-d-1])%mod
print(dp[-1])
0