結果

問題 No.980 Fibonacci Convolution Hard
ユーザー chinchillachinchilla
提出日時 2020-02-28 15:50:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,306 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 85,304 KB
最終ジャッジ日時 2024-04-21 17:34:53
合計ジャッジ時間 26,396 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,306 ms
84,932 KB
testcase_01 AC 1,199 ms
84,968 KB
testcase_02 AC 1,191 ms
85,052 KB
testcase_03 AC 1,191 ms
85,036 KB
testcase_04 AC 1,197 ms
84,920 KB
testcase_05 AC 1,208 ms
84,792 KB
testcase_06 AC 1,200 ms
84,652 KB
testcase_07 AC 1,218 ms
84,664 KB
testcase_08 AC 1,191 ms
84,796 KB
testcase_09 AC 1,195 ms
84,788 KB
testcase_10 AC 1,199 ms
84,792 KB
testcase_11 AC 1,197 ms
85,304 KB
testcase_12 AC 1,197 ms
84,796 KB
testcase_13 AC 1,204 ms
84,928 KB
testcase_14 AC 1,222 ms
84,796 KB
testcase_15 AC 1,204 ms
84,928 KB
testcase_16 AC 1,188 ms
85,180 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')]
for _ in range(1, 21): N += [N[-1]**2%m]
L = np.eye(1025, 2, 0, 'i8')
for i in range(10):
	L[1+2**i:1+2**(i+1)] = L[1:1+2**i] * N[i] % m
H = np.eye(2, 2048, -1, 'i8')
for i in range(11):
	H[:, 2**i:2**(i+1)] = N[10+i] * H[:, :2**i] % m
T = L @ H[:, :2*10**6//1024+1] % m
c01 = np.arange(2)[:, None]
C = M @ T[q%1024+c01, q//1024] % m
print(*((q*C[1]+C[0])%m), sep='\n')
0