結果

問題 No.978 Fibonacci Convolution Easy
ユーザー c-yan
提出日時 2020-11-28 00:32:51
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 359 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 91,008 KB
最終ジャッジ日時 2024-07-26 21:25:31
合計ジャッジ時間 2,520 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 RE * 1
権限があれば一括ダウンロードができます

ソースコード

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