結果

問題 No.978 Fibonacci Convolution Easy
ユーザー brthyyjp
提出日時 2020-12-19 02:02:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 186,632 KB
最終ジャッジ日時 2024-09-21 09:50:07
合計ジャッジ時間 5,235 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if n == 1:
    print(0)
    exit()

A = [0]*n
A[0] = 0
A[1] = 1
for i in range(2, n):
    A[i] = p*A[i-1]+A[i-2]
    A[i] %= mod

from itertools import accumulate
C = list(accumulate(A))
ans = 0
for a, c in zip(A, C):
    ans += a*c
    ans %= mod
print(ans)
0