結果

問題 No.2578 Jewelry Store
ユーザー 👑 p-adicp-adic
提出日時 2023-12-07 12:28:34
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 802 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 118,668 KB
最終ジャッジ日時 2023-12-07 12:28:45
合計ジャッジ時間 10,392 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 TLE -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
I=lambda:map(int,input().split())
T,m=I()
M=[m]
P=set()
def G(a,b):
	while a:a,b=b%a,a
	return b
while M:
	n=M.pop()
	if n in P:continue
	if n<999:
		for i in R(2,n+1):
			if n%i<1:
				P.add(i)
				while n%i<1:n//=i
	else:
		for t in R(999):
			x,d=t,1
			y=(x*x+1)%n
			while d<2:x,y,d=(x*x+1)%n,(y**4+2*y*y+2)%n,G(abs(x-y),n)
			if d<n:
				while n%d<1:n//=d
				M+=[d,n]
				break
		else:P.add(n)
P=list(P)
L=len(P)
E=[]
for i in R(L):
	n=m
	while n%P[i]<1:n//=P[i]
	E+=[m//n]
for t in R(T):
	N,B,C,D=I()
	A=list(I())
	b=[0]*N
	for i in R(L):
		for j in R(N):b[j]|=(A[j]%E[i]>0)*1<<i
	W=[]
	for a in A:
		W+=[1+B*(m%a<1)]
		B=(C*B+D)%Q
	v=0
	for d in R(1<<L):
		w,S=1,[i for i in R(L)if d>>i&1]
		for j in R(N):w*=[1,W[j]][all(b[j]>>i&1for i in S)]
		v+=[w,-w][len(S)%2]
	print((v-(m<2))%Q)
0