結果

問題 No.1025 Modular Equation
ユーザー convexineq
提出日時 2020-04-10 22:46:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 912 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 95,340 KB
最終ジャッジ日時 2024-09-15 22:55:57
合計ジャッジ時間 21,604 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

import numpy
from scipy.fftpack import fft, ifft
def FastConvolution(A,B): # A,B: 2^c 成分を想定
    return ifft(fft(A)*fft(B))

p,n,k,b,*a = [int(i) for i in read().split()]

M = 1
while M <= p: M <<= 1
M <<= 1
V = (-M)%p
q = (M+V)//p

lst = [0]*p
for i in range(p): lst[pow(i,k,p)] += 1

x = [1]+[0]*(M-1)

MOD = 10**9+7
#print(lst,"lst")
#print(p,q)
for ai in a:
    y = [0]*M
    for i,c in enumerate(lst):
        y[i*ai%p] += c

    #print(x,y)    
    x = FastConvolution(x,y)
    x = numpy.mod(numpy.round(numpy.real(x)).astype(int),MOD)
    z = numpy.reshape(numpy.append(x,[0]*V),[q,p])
    x = numpy.append(numpy.mod(numpy.sum(z, axis=0),MOD),[0]*(M-p))
    #x = numpy.sum(numpy.reshape(numpy.append(x,[0]*V),[p,q]))
    #print(x)
    
    #print(x)


print(x[b])

    
0