結果

問題 No.2578 Jewelry Store
ユーザー 👑 p-adicp-adic
提出日時 2023-12-07 16:42:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,354 ms / 3,500 ms
コード長 852 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 150,072 KB
最終ジャッジ日時 2023-12-07 16:42:45
合計ジャッジ時間 20,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 102 ms
77,076 KB
testcase_03 AC 90 ms
76,436 KB
testcase_04 AC 146 ms
76,464 KB
testcase_05 AC 107 ms
76,144 KB
testcase_06 AC 103 ms
77,080 KB
testcase_07 AC 139 ms
76,260 KB
testcase_08 AC 90 ms
76,448 KB
testcase_09 AC 134 ms
76,472 KB
testcase_10 AC 184 ms
76,376 KB
testcase_11 AC 97 ms
77,044 KB
testcase_12 AC 91 ms
76,440 KB
testcase_13 AC 108 ms
76,308 KB
testcase_14 AC 100 ms
76,788 KB
testcase_15 AC 95 ms
76,816 KB
testcase_16 AC 183 ms
76,380 KB
testcase_17 AC 136 ms
76,216 KB
testcase_18 AC 107 ms
76,256 KB
testcase_19 AC 116 ms
76,712 KB
testcase_20 AC 136 ms
76,464 KB
testcase_21 AC 139 ms
76,464 KB
testcase_22 AC 101 ms
77,072 KB
testcase_23 AC 104 ms
76,116 KB
testcase_24 AC 77 ms
72,752 KB
testcase_25 AC 95 ms
76,120 KB
testcase_26 AC 98 ms
76,836 KB
testcase_27 AC 309 ms
76,292 KB
testcase_28 AC 545 ms
76,528 KB
testcase_29 AC 498 ms
76,552 KB
testcase_30 AC 642 ms
77,064 KB
testcase_31 AC 303 ms
76,516 KB
testcase_32 AC 279 ms
107,872 KB
testcase_33 AC 331 ms
101,232 KB
testcase_34 AC 404 ms
106,800 KB
testcase_35 AC 152 ms
91,648 KB
testcase_36 AC 317 ms
109,112 KB
testcase_37 AC 246 ms
77,900 KB
testcase_38 AC 400 ms
77,644 KB
testcase_39 AC 239 ms
80,604 KB
testcase_40 AC 236 ms
76,412 KB
testcase_41 AC 255 ms
77,020 KB
testcase_42 AC 269 ms
77,148 KB
testcase_43 AC 294 ms
76,716 KB
testcase_44 AC 679 ms
76,764 KB
testcase_45 AC 294 ms
76,748 KB
testcase_46 AC 267 ms
78,200 KB
testcase_47 AC 1,076 ms
79,312 KB
testcase_48 AC 544 ms
150,072 KB
testcase_49 AC 2,294 ms
137,632 KB
testcase_50 AC 2,354 ms
149,280 KB
testcase_51 AC 247 ms
76,764 KB
testcase_52 AC 559 ms
77,144 KB
testcase_53 AC 109 ms
75,932 KB
権限があれば一括ダウンロードができます

ソースコード

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)*9
	if n<10**9:r(n)
	else:
		while c:
			x,d=c,1
			y=(x*x+1)%n
			while (d<2)*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
s=[1-len([1for i in R(L)if d>>i&1])%2*2for d in R(U)]
E=[[d for d in R(U)if d>>i&1<1]for i in R(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 E[i]:c[d]=c[d]*c[d|1<<i]%Q
	v=0
	for d in R(U):v+=c[d]*s[d]
	print((v-(m<2))%Q)
0