結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 113 ms
76,824 KB
testcase_03 AC 92 ms
76,308 KB
testcase_04 AC 190 ms
76,200 KB
testcase_05 AC 124 ms
77,164 KB
testcase_06 AC 128 ms
76,824 KB
testcase_07 AC 183 ms
76,236 KB
testcase_08 AC 93 ms
76,296 KB
testcase_09 AC 185 ms
76,456 KB
testcase_10 AC 271 ms
76,248 KB
testcase_11 AC 107 ms
76,136 KB
testcase_12 AC 94 ms
76,304 KB
testcase_13 AC 126 ms
76,680 KB
testcase_14 AC 105 ms
76,532 KB
testcase_15 AC 95 ms
76,556 KB
testcase_16 AC 273 ms
76,256 KB
testcase_17 AC 187 ms
76,200 KB
testcase_18 AC 95 ms
76,552 KB
testcase_19 AC 137 ms
76,708 KB
testcase_20 AC 216 ms
76,456 KB
testcase_21 AC 187 ms
76,456 KB
testcase_22 AC 105 ms
76,692 KB
testcase_23 AC 122 ms
76,104 KB
testcase_24 AC 82 ms
72,872 KB
testcase_25 AC 105 ms
75,976 KB
testcase_26 AC 104 ms
76,696 KB
testcase_27 AC 317 ms
76,292 KB
testcase_28 AC 632 ms
76,428 KB
testcase_29 AC 586 ms
76,576 KB
testcase_30 AC 814 ms
76,812 KB
testcase_31 AC 336 ms
76,396 KB
testcase_32 AC 278 ms
106,896 KB
testcase_33 AC 331 ms
100,708 KB
testcase_34 AC 396 ms
106,736 KB
testcase_35 AC 152 ms
92,040 KB
testcase_36 AC 317 ms
110,028 KB
testcase_37 AC 230 ms
77,132 KB
testcase_38 AC 403 ms
77,388 KB
testcase_39 AC 243 ms
80,220 KB
testcase_40 AC 236 ms
76,292 KB
testcase_41 AC 252 ms
76,892 KB
testcase_42 AC 254 ms
77,404 KB
testcase_43 AC 295 ms
76,588 KB
testcase_44 AC 705 ms
76,380 KB
testcase_45 AC 271 ms
77,644 KB
testcase_46 AC 269 ms
78,664 KB
testcase_47 AC 1,710 ms
78,288 KB
testcase_48 AC 527 ms
127,720 KB
testcase_49 TLE -
testcase_50 TLE -
testcase_51 AC 233 ms
76,764 KB
testcase_52 AC 692 ms
76,832 KB
testcase_53 AC 108 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)]
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]*s[d]
	print((v-(m<2))%Q)
0