結果

問題 No.978 Fibonacci Convolution Easy
ユーザー brthyyjpbrthyyjp
提出日時 2020-12-19 02:02:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 186,096 KB
最終ジャッジ日時 2023-10-21 08:46:15
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
67,056 KB
testcase_01 AC 175 ms
139,816 KB
testcase_02 AC 113 ms
106,528 KB
testcase_03 AC 328 ms
169,336 KB
testcase_04 AC 128 ms
115,052 KB
testcase_05 AC 64 ms
82,148 KB
testcase_06 AC 151 ms
126,848 KB
testcase_07 AC 234 ms
151,040 KB
testcase_08 AC 173 ms
141,148 KB
testcase_09 AC 265 ms
152,676 KB
testcase_10 AC 332 ms
186,036 KB
testcase_11 AC 141 ms
120,540 KB
testcase_12 AC 64 ms
81,004 KB
testcase_13 AC 148 ms
126,756 KB
testcase_14 AC 79 ms
88,608 KB
testcase_15 AC 165 ms
133,432 KB
testcase_16 AC 341 ms
186,096 KB
testcase_17 AC 346 ms
186,068 KB
testcase_18 AC 34 ms
53,400 KB
testcase_19 AC 35 ms
53,464 KB
testcase_20 AC 35 ms
53,464 KB
権限があれば一括ダウンロードができます

ソースコード

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