結果

問題 No.980 Fibonacci Convolution Hard
ユーザー Eki1009Eki1009
提出日時 2020-11-01 18:25:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 562 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 93,536 KB
最終ジャッジ日時 2023-09-29 11:21:53
合計ジャッジ時間 12,660 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 548 ms
93,240 KB
testcase_01 AC 550 ms
93,032 KB
testcase_02 AC 551 ms
93,216 KB
testcase_03 AC 551 ms
93,416 KB
testcase_04 AC 547 ms
93,168 KB
testcase_05 AC 550 ms
93,360 KB
testcase_06 AC 559 ms
93,536 KB
testcase_07 AC 562 ms
93,376 KB
testcase_08 AC 556 ms
93,328 KB
testcase_09 AC 548 ms
93,056 KB
testcase_10 AC 553 ms
93,088 KB
testcase_11 AC 543 ms
93,176 KB
testcase_12 AC 548 ms
93,344 KB
testcase_13 AC 548 ms
93,432 KB
testcase_14 AC 548 ms
93,332 KB
testcase_15 AC 553 ms
93,268 KB
testcase_16 AC 517 ms
93,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9+7
m = 2*10**6
p = int(input())
C = [(2*p)%mod, (2-p**2)%mod, (-2*p)%mod, -1]
E = [0]*(m+1)
E[3] = 1
for i in range(4, m+1):
    E[i] = C[0]*E[i-1] + C[1]*E[i-2] + C[2]*E[i-3] + C[3]*E[i-4]
    E[i] %= mod
q = int(input())
for _ in range(q):
    n = int(input())
    print(E[n-1])
0