結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 177 ms
76,804 KB
testcase_03 AC 117 ms
76,320 KB
testcase_04 AC 421 ms
76,720 KB
testcase_05 AC 117 ms
76,264 KB
testcase_06 AC 182 ms
76,812 KB
testcase_07 AC 444 ms
76,836 KB
testcase_08 AC 117 ms
76,336 KB
testcase_09 AC 413 ms
76,720 KB
testcase_10 AC 738 ms
77,632 KB
testcase_11 AC 111 ms
76,272 KB
testcase_12 AC 119 ms
76,300 KB
testcase_13 AC 109 ms
76,556 KB
testcase_14 AC 112 ms
76,280 KB
testcase_15 AC 123 ms
76,924 KB
testcase_16 AC 718 ms
77,632 KB
testcase_17 AC 425 ms
76,848 KB
testcase_18 AC 119 ms
76,340 KB
testcase_19 AC 250 ms
76,576 KB
testcase_20 AC 421 ms
76,724 KB
testcase_21 AC 437 ms
76,720 KB
testcase_22 AC 155 ms
76,696 KB
testcase_23 AC 218 ms
76,096 KB
testcase_24 AC 117 ms
75,836 KB
testcase_25 AC 158 ms
75,848 KB
testcase_26 AC 144 ms
76,444 KB
testcase_27 AC 359 ms
76,332 KB
testcase_28 AC 1,022 ms
78,292 KB
testcase_29 AC 1,041 ms
78,416 KB
testcase_30 AC 1,734 ms
82,780 KB
testcase_31 AC 354 ms
76,456 KB
testcase_32 AC 301 ms
101,932 KB
testcase_33 AC 337 ms
96,844 KB
testcase_34 AC 413 ms
120,340 KB
testcase_35 AC 152 ms
91,896 KB
testcase_36 AC 321 ms
112,788 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
while M:
	n=M.pop()
	if n in P:continue
	if n<99:
		i=2
		while i*i<=n:
			if n%i<1:
				P.add(i)
				while n%i<1:n//=i
			i+=1
		if n>1:P.add(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:
				while n%d<1:n//=d
				M+=[d,n]
				break
		else:P.add(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