結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 177 ms
76,564 KB
testcase_03 AC 120 ms
76,328 KB
testcase_04 AC 424 ms
76,736 KB
testcase_05 AC 121 ms
76,388 KB
testcase_06 AC 179 ms
76,820 KB
testcase_07 AC 429 ms
76,768 KB
testcase_08 AC 121 ms
76,344 KB
testcase_09 AC 425 ms
76,736 KB
testcase_10 AC 752 ms
77,656 KB
testcase_11 AC 116 ms
76,272 KB
testcase_12 AC 121 ms
76,312 KB
testcase_13 AC 111 ms
76,556 KB
testcase_14 AC 116 ms
76,288 KB
testcase_15 AC 134 ms
76,872 KB
testcase_16 AC 741 ms
77,656 KB
testcase_17 AC 423 ms
76,736 KB
testcase_18 AC 123 ms
76,360 KB
testcase_19 AC 258 ms
76,468 KB
testcase_20 AC 422 ms
76,736 KB
testcase_21 AC 416 ms
76,736 KB
testcase_22 AC 156 ms
76,708 KB
testcase_23 AC 222 ms
76,128 KB
testcase_24 AC 121 ms
76,100 KB
testcase_25 AC 162 ms
76,112 KB
testcase_26 AC 144 ms
76,324 KB
testcase_27 AC 355 ms
77,112 KB
testcase_28 AC 1,046 ms
78,440 KB
testcase_29 AC 1,072 ms
78,308 KB
testcase_30 AC 1,736 ms
83,016 KB
testcase_31 AC 354 ms
76,584 KB
testcase_32 AC 286 ms
104,180 KB
testcase_33 AC 343 ms
96,640 KB
testcase_34 AC 430 ms
120,192 KB
testcase_35 AC 152 ms
91,904 KB
testcase_36 AC 325 ms
113,116 KB
testcase_37 AC 231 ms
77,108 KB
testcase_38 AC 276 ms
76,888 KB
testcase_39 AC 231 ms
79,540 KB
testcase_40 AC 250 ms
77,444 KB
testcase_41 AC 249 ms
77,056 KB
testcase_42 AC 242 ms
77,016 KB
testcase_43 WA -
testcase_44 AC 246 ms
76,760 KB
testcase_45 AC 279 ms
76,928 KB
testcase_46 AC 231 ms
78,996 KB
testcase_47 TLE -
testcase_48 AC 563 ms
146,452 KB
testcase_49 TLE -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
I=lambda:map(int,input().split())
T,m=I()
P,n=set(),m
for i in R(2,min(m+1,31623)):
	if n%i<1:P.add(i)
	while n%i<1:n//=i
M=[n]*(n>1)
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()
	c=int(n**0.25)
	if n<10**9:r(n)
	else:
		while c:
			x,d=c,1
			y=(x*x+1)%n
			while d<2 and c:x,y,d,c=(x*x+1)%n,(y**4+2*y*y+2)%n,G(abs(x-y),n),c-1
			if d<n and c:
				M+=[n//d,d]
				break
		else: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