結果

問題 No.980 Fibonacci Convolution Hard
ユーザー titiatitia
提出日時 2020-02-28 06:21:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 513 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 230,056 KB
最終ジャッジ日時 2024-04-21 17:25:16
合計ジャッジ時間 11,903 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 506 ms
206,468 KB
testcase_01 AC 504 ms
206,468 KB
testcase_02 AC 505 ms
206,568 KB
testcase_03 AC 512 ms
206,688 KB
testcase_04 AC 513 ms
206,304 KB
testcase_05 AC 505 ms
206,436 KB
testcase_06 AC 506 ms
206,824 KB
testcase_07 AC 511 ms
206,444 KB
testcase_08 AC 506 ms
206,432 KB
testcase_09 AC 511 ms
206,436 KB
testcase_10 AC 504 ms
206,692 KB
testcase_11 AC 508 ms
206,308 KB
testcase_12 AC 508 ms
206,556 KB
testcase_13 AC 506 ms
206,816 KB
testcase_14 AC 507 ms
206,648 KB
testcase_15 AC 507 ms
206,312 KB
testcase_16 AC 217 ms
230,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
mod=1000000007

p=int(input())
q=int(input())
Q=[int(input()) for i in range(q)]

ANS=[0,0,0,0]

A=[0,1]
A.append(p*A[-1]+A[-2])
A.append(p*A[-1]+A[-2])

ANS[2]=(A[0]*A[2]*2+A[1]*A[1])%mod
ANS[3]=(A[0]*A[3]*2+A[1]*A[2]*2)%mod

for i in range(2*10**6):
    ANS.append((2*p*ANS[-1]-(p**2-2)*ANS[-2]-2*p*ANS[-3]-ANS[-4])%mod)

for q in Q:
    print(ANS[q-2])
0