結果

問題 No.2798 Multiple Chain
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-06-28 22:01:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 1,963 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 128,380 KB
最終ジャッジ日時 2024-06-28 22:01:57
合計ジャッジ時間 9,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
128,188 KB
testcase_01 AC 151 ms
128,200 KB
testcase_02 AC 152 ms
128,284 KB
testcase_03 AC 160 ms
128,164 KB
testcase_04 AC 147 ms
128,272 KB
testcase_05 AC 149 ms
128,108 KB
testcase_06 AC 156 ms
128,056 KB
testcase_07 AC 163 ms
127,924 KB
testcase_08 AC 149 ms
128,364 KB
testcase_09 AC 149 ms
128,124 KB
testcase_10 AC 148 ms
128,316 KB
testcase_11 AC 151 ms
128,368 KB
testcase_12 AC 149 ms
128,040 KB
testcase_13 AC 146 ms
128,372 KB
testcase_14 AC 150 ms
128,296 KB
testcase_15 AC 149 ms
128,044 KB
testcase_16 AC 144 ms
128,376 KB
testcase_17 AC 147 ms
128,292 KB
testcase_18 AC 148 ms
128,140 KB
testcase_19 AC 163 ms
128,304 KB
testcase_20 AC 155 ms
128,240 KB
testcase_21 AC 156 ms
128,204 KB
testcase_22 AC 149 ms
128,108 KB
testcase_23 AC 149 ms
128,252 KB
testcase_24 AC 149 ms
128,252 KB
testcase_25 AC 150 ms
128,188 KB
testcase_26 AC 160 ms
128,024 KB
testcase_27 AC 154 ms
128,380 KB
testcase_28 AC 155 ms
128,220 KB
testcase_29 AC 155 ms
128,016 KB
testcase_30 AC 153 ms
126,340 KB
testcase_31 AC 158 ms
127,964 KB
testcase_32 AC 159 ms
120,704 KB
testcase_33 AC 153 ms
126,264 KB
testcase_34 AC 148 ms
114,576 KB
testcase_35 AC 161 ms
128,188 KB
testcase_36 AC 161 ms
127,524 KB
testcase_37 AC 148 ms
128,372 KB
testcase_38 AC 147 ms
125,176 KB
testcase_39 AC 147 ms
128,028 KB
testcase_40 AC 148 ms
128,204 KB
testcase_41 AC 149 ms
128,168 KB
testcase_42 AC 145 ms
128,324 KB
testcase_43 AC 155 ms
128,228 KB
testcase_44 AC 154 ms
128,212 KB
testcase_45 AC 149 ms
127,980 KB
testcase_46 AC 148 ms
128,292 KB
testcase_47 AC 149 ms
128,184 KB
testcase_48 AC 146 ms
128,156 KB
testcase_49 AC 174 ms
128,308 KB
testcase_50 AC 148 ms
127,996 KB
testcase_51 AC 150 ms
128,108 KB
testcase_52 AC 147 ms
124,340 KB
testcase_53 AC 149 ms
127,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
import math
from collections import deque,Counter
def is_prime(n:int)->bool:
    if n%2==0:
        return n==2
    if n<=1:
        return False
    d=n-1
    s=0
    while (d&1)==0:
        d>>=1
        s+=1
    if n<4759123141:
        for a in (2,7,61):
            if a==n:
                continue
            power=pow(a,d,n)
            if power!=1:
                for r in range(s+1):
                    if r==s:
                        return False
                    if power==n-1:
                        break
                    power=(power*power)%n
    else:
        for a in (2,325,9375,28178,450775,9780504,1796265022):
            power=pow(a,d,n)
            if power!=1:
                for r in range(s+1):
                    if r==s:
                        return False
                    if power==n-1:
                        break
                    power=(power*power)%n
    return True

def prime_fact(n:int):
    ret=[]
    for i in range(2,100):
        while n%i==0:
            ret.append(i)
            n=n//i
    if n==1:
        return ret
    calc=deque([n])
    while len(calc)>0:
        n=calc.pop()
        while not is_prime(n):
            x=random.randint(0,n-1)
            y=x
            c=random.randint(1,n-1)
            i=0
            while True:
                x=(x*x+c)%n
                y=(y*y+c)%n
                y=(y*y+c)%n
                d=math.gcd(abs(x-y),n)
                if d==1:
                    i+=1
                else:
                    if d!=n and d!=n:
                        calc.append(d)
                        n//=d
                    break
        ret.append(n)
    return sorted(ret)

dp=[[0]*1001 for i in range(1001)]
N=int(input())
fact=Counter(prime_fact(N))
dp[0][0]=1
for i in range(1,1001):
	for j in range(1001):
		if j-i>=0:
			dp[i][j]=dp[i-1][j]+dp[i][j-i]
		else:
			dp[i][j]=dp[i-1][j]
ans=1
for i in fact:
	ans*=dp[1000][fact[i]]
print(ans)
0