結果

問題 No.1892 Extended Fib Series
ユーザー lloyzlloyz
提出日時 2022-05-14 01:10:35
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 77,180 KB
最終ジャッジ日時 2023-09-29 11:42:51
合計ジャッジ時間 5,005 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,276 KB
testcase_01 AC 108 ms
77,032 KB
testcase_02 AC 72 ms
71,448 KB
testcase_03 AC 72 ms
71,276 KB
testcase_04 AC 88 ms
76,740 KB
testcase_05 AC 72 ms
71,280 KB
testcase_06 AC 114 ms
77,100 KB
testcase_07 AC 80 ms
76,964 KB
testcase_08 AC 91 ms
76,824 KB
testcase_09 AC 86 ms
76,976 KB
testcase_10 AC 86 ms
76,652 KB
testcase_11 AC 73 ms
71,388 KB
testcase_12 AC 88 ms
76,464 KB
testcase_13 AC 96 ms
76,976 KB
testcase_14 AC 72 ms
71,136 KB
testcase_15 AC 72 ms
71,124 KB
testcase_16 AC 73 ms
71,112 KB
testcase_17 AC 72 ms
71,356 KB
testcase_18 AC 73 ms
71,268 KB
testcase_19 AC 74 ms
71,280 KB
testcase_20 AC 74 ms
71,388 KB
testcase_21 AC 73 ms
71,120 KB
testcase_22 AC 74 ms
71,336 KB
testcase_23 AC 72 ms
71,384 KB
testcase_24 AC 73 ms
71,456 KB
testcase_25 AC 72 ms
71,372 KB
testcase_26 AC 72 ms
71,316 KB
testcase_27 AC 72 ms
71,568 KB
testcase_28 AC 73 ms
71,276 KB
testcase_29 AC 78 ms
76,960 KB
testcase_30 AC 77 ms
77,020 KB
testcase_31 AC 78 ms
76,948 KB
testcase_32 AC 118 ms
77,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, l = map(int, input().split())
mod = 10**9 + 7

if n < l:
    print(pow(2, n - 1, mod))
    exit()

DP = [0 for _ in range(n + 1)]
DP[0] = 1
for i in range(1, l):
    DP[i] = pow(2, i - 1, mod)
s = 0
for i in range(l):
    s += DP[i]
    s %= mod
for i in range(l, n + 1):
    DP[i] = s
    s -= DP[i - l]
    s += DP[i]
    s %= mod
print(DP[n])
0