提出 #7803795
ソースコード 拡げる
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
import numpy as np
K,M = map(int,readline().split())
A = np.array(readline().split(),np.int64)
C = np.array(readline().split(),np.int64)
A,C
K
mask = (1<<32)-1
mat = np.eye(K,K,-1,np.int64) * mask
mat[0] = C
def mat_prod(A,B):
a,b = A.shape
c,d = B.shape
assert b == c
return np.bitwise_xor.reduce(A[:,:,None] & B[None,:,:],axis=1)
def mat_power(A,N):
if N == 0:
return np.eye(K,dtype=np.int64) * mask
mat = mat_power(A,N//2)
mat = mat_prod(mat,mat)
return mat_prod(mat,A) if N&1 else mat
x = mat_power(mat,M-1)
v = mat_prod(x,A[::-1].reshape(-1,1))
answer = v[-1,0]
print(answer)
提出情報
| 提出日時 |
|
| 問題 |
D - 漸化式 |
| ユーザ |
maspy |
| 言語 |
Python (3.4.3) |
| 得点 |
100 |
| コード長 |
811 Byte |
| 結果 |
AC |
| 実行時間 |
303 ms |
| メモリ |
20592 KiB |
ジャッジ結果
| セット名 |
All |
| 得点 / 配点 |
100 / 100 |
| 結果 |
|
| セット名 |
テストケース |
| All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_1.txt, sample_2.txt, sample_3.txt, small_1.txt, small_2.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| random_01.txt |
AC |
149 ms |
12508 KiB |
| random_02.txt |
AC |
148 ms |
12424 KiB |
| random_03.txt |
AC |
149 ms |
12424 KiB |
| random_04.txt |
AC |
148 ms |
12384 KiB |
| random_05.txt |
AC |
150 ms |
12428 KiB |
| random_06.txt |
AC |
149 ms |
12428 KiB |
| random_07.txt |
AC |
155 ms |
12876 KiB |
| random_08.txt |
AC |
173 ms |
13560 KiB |
| random_09.txt |
AC |
294 ms |
20348 KiB |
| random_10.txt |
AC |
301 ms |
20560 KiB |
| random_11.txt |
AC |
302 ms |
20560 KiB |
| random_12.txt |
AC |
302 ms |
20476 KiB |
| random_13.txt |
AC |
302 ms |
20592 KiB |
| random_14.txt |
AC |
303 ms |
20560 KiB |
| random_15.txt |
AC |
282 ms |
20476 KiB |
| sample_1.txt |
AC |
148 ms |
12512 KiB |
| sample_2.txt |
AC |
148 ms |
12428 KiB |
| sample_3.txt |
AC |
155 ms |
12796 KiB |
| small_1.txt |
AC |
150 ms |
12428 KiB |
| small_2.txt |
AC |
150 ms |
12424 KiB |