結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
c-yan
|
| 提出日時 | 2020-11-28 00:34:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| コード長 | 365 bytes |
| コンパイル時間 | 178 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 90,624 KB |
| 最終ジャッジ日時 | 2024-07-26 21:25:33 |
| 合計ジャッジ時間 | 2,399 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
from itertools import accumulate
N, p = map(int, input().split())
m = 1000000007
a = [0] * max(N + 1, 3)
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)
c-yan