結果

問題 No.978 Fibonacci Convolution Easy
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-01-18 07:00:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 93,260 KB
最終ジャッジ日時 2023-09-02 03:36:59
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
77,760 KB
testcase_01 AC 107 ms
83,716 KB
testcase_02 AC 108 ms
80,780 KB
testcase_03 AC 126 ms
92,588 KB
testcase_04 AC 107 ms
81,648 KB
testcase_05 AC 98 ms
78,312 KB
testcase_06 AC 108 ms
83,000 KB
testcase_07 AC 116 ms
87,412 KB
testcase_08 AC 113 ms
84,348 KB
testcase_09 AC 120 ms
88,656 KB
testcase_10 AC 127 ms
93,248 KB
testcase_11 AC 106 ms
82,312 KB
testcase_12 AC 101 ms
78,316 KB
testcase_13 AC 110 ms
82,580 KB
testcase_14 AC 104 ms
78,960 KB
testcase_15 AC 108 ms
83,584 KB
testcase_16 AC 123 ms
93,260 KB
testcase_17 AC 122 ms
93,244 KB
testcase_18 AC 96 ms
73,000 KB
testcase_19 AC 97 ms
73,008 KB
testcase_20 AC 93 ms
72,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,p = map(int,input().split())
mod = 10**9 + 7
if N==1:
    print(0)
    exit()
a = [0]*(N+1)
a[2]=1
ans = 0
S = 0

ans = 1
S = 1
for i in range(3,N+1):
    a[i]=(p*a[i-1]+a[i-2])%mod
    S += a[i]
    ans += S*a[i]
    ans %= mod
    S %= mod
print(ans)

0