結果

問題 No.978 Fibonacci Convolution Easy
ユーザー 👑 KazunKazun
提出日時 2021-01-01 17:49:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 258 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 105,600 KB
最終ジャッジ日時 2024-04-19 19:55:28
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
59,264 KB
testcase_01 AC 54 ms
77,056 KB
testcase_02 AC 47 ms
67,712 KB
testcase_03 AC 77 ms
103,680 KB
testcase_04 AC 50 ms
70,272 KB
testcase_05 AC 39 ms
60,928 KB
testcase_06 AC 52 ms
74,368 KB
testcase_07 AC 61 ms
87,680 KB
testcase_08 AC 55 ms
78,720 KB
testcase_09 AC 72 ms
91,904 KB
testcase_10 AC 79 ms
105,600 KB
testcase_11 AC 53 ms
72,064 KB
testcase_12 AC 41 ms
60,928 KB
testcase_13 AC 53 ms
74,240 KB
testcase_14 AC 42 ms
63,104 KB
testcase_15 AC 54 ms
76,416 KB
testcase_16 AC 81 ms
105,472 KB
testcase_17 AC 81 ms
105,472 KB
testcase_18 AC 34 ms
52,096 KB
testcase_19 AC 33 ms
51,584 KB
testcase_20 AC 31 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,p=map(int,input().split())
Mod=10**9+7

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

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

two_inv=pow(2,Mod-2,Mod)
A=A[1:]

X=(sum(A)**2)%Mod
Y=sum([a*a%Mod for a in A])%Mod
print(two_inv*(X+Y)%Mod)
0