結果

問題 No.1892 Extended Fib Series
ユーザー 👑 rin204rin204
提出日時 2022-09-27 22:30:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 77,496 KB
最終ジャッジ日時 2023-08-24 04:09:26
合計ジャッジ時間 5,305 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,920 KB
testcase_01 AC 79 ms
77,012 KB
testcase_02 AC 78 ms
76,896 KB
testcase_03 AC 76 ms
75,660 KB
testcase_04 AC 82 ms
76,612 KB
testcase_05 AC 77 ms
75,664 KB
testcase_06 AC 82 ms
77,316 KB
testcase_07 AC 79 ms
76,888 KB
testcase_08 AC 82 ms
77,112 KB
testcase_09 AC 81 ms
77,236 KB
testcase_10 AC 80 ms
76,464 KB
testcase_11 AC 76 ms
75,816 KB
testcase_12 AC 81 ms
76,364 KB
testcase_13 AC 82 ms
77,192 KB
testcase_14 AC 73 ms
71,076 KB
testcase_15 AC 71 ms
71,084 KB
testcase_16 AC 73 ms
71,048 KB
testcase_17 AC 72 ms
70,836 KB
testcase_18 AC 72 ms
71,288 KB
testcase_19 AC 71 ms
71,344 KB
testcase_20 AC 71 ms
70,836 KB
testcase_21 AC 72 ms
71,084 KB
testcase_22 AC 74 ms
71,088 KB
testcase_23 AC 74 ms
71,164 KB
testcase_24 AC 73 ms
71,016 KB
testcase_25 AC 73 ms
70,980 KB
testcase_26 AC 72 ms
71,016 KB
testcase_27 AC 73 ms
71,188 KB
testcase_28 AC 74 ms
71,092 KB
testcase_29 AC 79 ms
77,216 KB
testcase_30 AC 77 ms
77,392 KB
testcase_31 AC 79 ms
77,168 KB
testcase_32 AC 80 ms
77,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n, l = map(int, input().split())
dp = [0] * (n + 1)
dp[0] = 1
cum = [0] * (n + 1)
cum[0] = 1

for i in range(1, n + 1):
    dp[i] = cum[i - 1]
    if i - l >= 1:
        dp[i] -= cum[i - l - 1]
    dp[i] %= MOD
    cum[i] = cum[i - 1] + dp[i]
    cum[i] %= MOD
print(dp[-1])
0