結果

問題 No.2578 Jewelry Store
ユーザー 👑 p-adicp-adic
提出日時 2023-12-07 08:52:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 270,196 KB
最終ジャッジ日時 2023-12-07 08:52:21
合計ジャッジ時間 18,139 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 223 ms
78,644 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 193 ms
78,712 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 208 ms
79,516 KB
testcase_15 AC 233 ms
78,932 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
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]*(m>1)
P=[]
def gcd(a,b):
	while a:a,b=b%a,a
	return b
while M:
	n=M.pop()
	if n<99:
		for i in R(2,n):
			if n%i<1:
				P+=[i]
				while n%i<1:n//=i
	else:
		for t in R(int(n**0.25)*2+9):
			x,d=int(n**0.5)+1,1
			y=(x*x+1)%n
			while d<2:x,y,d=(x*x+1)%n,(y**4+2*y*y+2)%n,gcd(abs(x-y),n)
			if d<n:
				M+=[d]
				while n%d<1:n//=d
				M+=[n]*(n>0)
				break
		else:P+=[n]
L=len(P)
Q=998244353
for t in R(T):
	N,B,C,D=I()
	A=list(I())
	b=[0]*N
	for i in R(L):
		n=m
		while n%P[i]<1:n//=P[i]
		for j in R(N):b[j]|=(A[j]%(m//n)>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