結果

問題 No.980 Fibonacci Convolution Hard
ユーザー chinchillachinchilla
提出日時 2020-02-29 13:19:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,310 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 114 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 103,964 KB
最終ジャッジ日時 2024-04-21 21:34:05
合計ジャッジ時間 27,726 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,301 ms
101,160 KB
testcase_01 AC 1,283 ms
100,972 KB
testcase_02 AC 1,291 ms
99,308 KB
testcase_03 AC 1,300 ms
99,608 KB
testcase_04 AC 1,286 ms
99,024 KB
testcase_05 AC 1,307 ms
100,612 KB
testcase_06 AC 1,296 ms
102,240 KB
testcase_07 AC 1,288 ms
100,452 KB
testcase_08 AC 1,288 ms
102,076 KB
testcase_09 AC 1,298 ms
101,284 KB
testcase_10 AC 1,310 ms
103,440 KB
testcase_11 AC 1,308 ms
102,372 KB
testcase_12 AC 1,302 ms
102,672 KB
testcase_13 AC 1,298 ms
103,296 KB
testcase_14 AC 1,303 ms
102,596 KB
testcase_15 AC 1,277 ms
103,964 KB
testcase_16 AC 1,262 ms
100,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, numpy as np
m = 10**9+7
p, _ = int(input()), input()
q = np.genfromtxt(sys.stdin, int) - 2
M = np.asarray([[-p, 0], [-p, 2]], 'i8')*pow(4+p**2, -1, m)%m
N = np.matrix([[0, 1], [1, p]], 'i8')
T = np.eye(2, 2**21, -1, 'i8')
for i in range(21):
	T[:, 2**i:2**(i+1)] = N * T[:, :2**i] % m
	N = N**2%m
C = M @ T[:, q] % m
print(*((q*C[1]+C[0])%m), sep='\n')
0