結果

問題 No.2798 Multiple Chain
ユーザー 👑 p-adic
提出日時 2024-07-07 19:39:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 781 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-07-07 19:40:02
合計ジャッジ時間 9,215 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
n=int(input())
P,t=set(),n
for i in R(2,min(n+1,31623)):
	if t%i<1:P.add(i)
	while t%i<1:t//=i
D=[t]*(t>1)
def G(a,b):
	while a:a,b=b%a,a
	return b
def r(t):
	for j in R(len(D)):
		while D[j]%t<1:D[j]//=t
	P.add(t)
while D:
	t=D.pop()
	c=int(t**0.25)*9
	if t<10**9:r(t)
	else:
		while c:
			x,d=c,1
			y=(x*x+1)%t
			while (d<2)*c:x,y,d,c=(x*x+1)%t,(y**4+2*y*y+2)%t,G(abs(x-y),t),c-1
			if d<t and c:
				D+=[t//d,d]
				break
		else:r(t)
P=list(P)
L=1
D=[]
for i in R(len(P)):
	p,c=P[i],0
	while n%p<1:n//=p;c+=1
	P[i]=[p,c]
	assert(c)
	L+=c
	D+=[[[s<1]*(s+1)for s in R(c+1)]]
assert(n<2)
for l in R(L):
	a=0
	t=1
	for i in R(len(P)):p,c=P[i];D[i]=[[sum(D[i][s-d][e]for e in R(min(s-d,d)+1))for d in R(s+1)]for s in R(c+1)];t*=sum(D[i][c][d]for d in R(c+1))
	a+=t
print(a)
0