結果

問題 No.978 Fibonacci Convolution Easy
ユーザー c-yanc-yan
提出日時 2020-11-28 00:32:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 359 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 164,796 KB
最終ジャッジ日時 2023-10-09 22:57:30
合計ジャッジ時間 21,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
9,820 KB
testcase_01 AC 927 ms
68,904 KB
testcase_02 AC 466 ms
38,728 KB
testcase_03 TLE -
testcase_04 AC 556 ms
46,196 KB
testcase_05 AC 134 ms
15,944 KB
testcase_06 AC 806 ms
60,528 KB
testcase_07 AC 1,418 ms
105,308 KB
testcase_08 AC 1,002 ms
74,920 KB
testcase_09 AC 1,633 ms
119,800 KB
testcase_10 TLE -
testcase_11 AC 666 ms
52,392 KB
testcase_12 AC 119 ms
15,092 KB
testcase_13 AC 768 ms
59,804 KB
testcase_14 AC 228 ms
22,424 KB
testcase_15 AC 865 ms
67,180 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 RE -
testcase_19 AC 16 ms
8,092 KB
testcase_20 AC 16 ms
8,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

N, p = map(int, input().split())

m = 1000000007

a = [0] * (N + 1)
a[1] = 0
a[2] = 1
for i in range(3, N + 1):
    a[i] = (p * a[i - 1] + a[i - 2]) % m

c = [0] * (N + 1)
for i in range(1, N + 1):
    c[i] = (c[i - 1] + a[i]) % m

result = 0
for i in range(1, N + 1):
    result += a[i] * c[i]
    result %= m
print(result)
0