結果

問題 No.1892 Extended Fib Series
ユーザー yassu0320yassu0320
提出日時 2022-04-04 22:33:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 63,300 KB
最終ジャッジ日時 2024-05-04 07:26:34
合計ジャッジ時間 2,665 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,136 KB
testcase_01 AC 63 ms
63,300 KB
testcase_02 AC 36 ms
53,512 KB
testcase_03 AC 34 ms
52,980 KB
testcase_04 AC 48 ms
61,364 KB
testcase_05 AC 34 ms
52,476 KB
testcase_06 AC 73 ms
63,004 KB
testcase_07 AC 37 ms
60,384 KB
testcase_08 AC 48 ms
61,816 KB
testcase_09 AC 43 ms
61,588 KB
testcase_10 AC 47 ms
61,348 KB
testcase_11 AC 32 ms
52,752 KB
testcase_12 AC 46 ms
61,668 KB
testcase_13 AC 51 ms
61,808 KB
testcase_14 AC 33 ms
52,828 KB
testcase_15 AC 33 ms
53,824 KB
testcase_16 AC 33 ms
52,468 KB
testcase_17 AC 32 ms
52,684 KB
testcase_18 AC 32 ms
52,784 KB
testcase_19 AC 31 ms
52,488 KB
testcase_20 AC 32 ms
53,624 KB
testcase_21 AC 33 ms
53,012 KB
testcase_22 AC 33 ms
52,932 KB
testcase_23 AC 33 ms
52,000 KB
testcase_24 AC 34 ms
52,892 KB
testcase_25 AC 34 ms
52,748 KB
testcase_26 AC 33 ms
53,000 KB
testcase_27 AC 33 ms
53,080 KB
testcase_28 AC 32 ms
53,840 KB
testcase_29 AC 37 ms
60,448 KB
testcase_30 AC 38 ms
61,500 KB
testcase_31 AC 36 ms
61,336 KB
testcase_32 AC 74 ms
61,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, l = input().split()
n = int(n)
l = int(l)
mod = 1000000007

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

a = [None] * (n + 1)
a[0] = 1
for i in range(1, l):
    a[i] = pow(2, i - 1, mod)

s = 0
for i in range(l):
    s += a[i]
    s %= mod

for i in range(l, n + 1):
    a[i] = s
    s -= a[i - l]
    s += a[i]
    s %= mod

# print(a)
print(a[-1])
0