結果

問題 No.2578 Jewelry Store
ユーザー 👑 p-adicp-adic
提出日時 2023-12-07 14:55:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 822 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 120,336 KB
最終ジャッジ日時 2023-12-07 14:55:39
合計ジャッジ時間 20,411 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 173 ms
76,800 KB
testcase_03 AC 120 ms
76,316 KB
testcase_04 AC 419 ms
76,716 KB
testcase_05 AC 115 ms
76,260 KB
testcase_06 AC 176 ms
76,680 KB
testcase_07 AC 420 ms
76,852 KB
testcase_08 AC 117 ms
76,332 KB
testcase_09 AC 408 ms
76,716 KB
testcase_10 AC 719 ms
77,628 KB
testcase_11 AC 110 ms
76,272 KB
testcase_12 AC 116 ms
76,296 KB
testcase_13 AC 106 ms
76,556 KB
testcase_14 AC 111 ms
76,276 KB
testcase_15 AC 122 ms
76,936 KB
testcase_16 AC 722 ms
77,628 KB
testcase_17 AC 408 ms
76,844 KB
testcase_18 AC 117 ms
76,336 KB
testcase_19 AC 251 ms
76,572 KB
testcase_20 AC 417 ms
76,716 KB
testcase_21 AC 404 ms
76,716 KB
testcase_22 AC 151 ms
76,692 KB
testcase_23 AC 219 ms
76,092 KB
testcase_24 AC 117 ms
75,832 KB
testcase_25 AC 161 ms
75,972 KB
testcase_26 AC 140 ms
76,444 KB
testcase_27 AC 350 ms
76,328 KB
testcase_28 AC 1,045 ms
78,288 KB
testcase_29 AC 1,029 ms
78,412 KB
testcase_30 AC 1,731 ms
82,788 KB
testcase_31 AC 352 ms
76,580 KB
testcase_32 AC 287 ms
101,900 KB
testcase_33 AC 342 ms
96,844 KB
testcase_34 AC 409 ms
120,336 KB
testcase_35 AC 148 ms
91,908 KB
testcase_36 AC 320 ms
113,284 KB
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
def r(n):
	for j in R(len(M)):
		while M[j]%n<1:M[j]//=n
	P.add(n)
while M:
	n=M.pop()
	if n<99:
		i=2
		while i*i<=n:
			if n%i<1 and not i in P:r(i)
			while n%i<1:n//=i
			i+=1
		if n>1 and not n in P:r(n)
	else:
		for t in R(99):
			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:
				M+=[d,n//d]
				break
		else:
			if not n in P:r(n)
P=list(P)
L=len(P)
Q=998244353
U=1<<L
for t in R(T):
	N,B,C,D=I()
	c=[1]*U
	for a in I():
		b=0
		for i in R(L):b|=(m//a%P[i]<1)<<i
		c[b],B=c[b]*(1+B*(m%a<1))%Q,(C*B+D)%Q
	for i in R(L):
		for d in R(U):
			if d>>i&1<1:c[d]=c[d]*c[d|1<<i]%Q
	v=0
	for d in R(U):v+=c[d]*[1,-1][len([1for i in R(L)if d>>i&1])%2]
	print((v-(m<2))%Q)
0