結果

問題 No.1973 Divisor Sequence
ユーザー prussian_coderprussian_coder
提出日時 2022-06-10 22:08:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 488 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 76,396 KB
最終ジャッジ日時 2023-10-21 06:20:41
合計ジャッジ時間 4,777 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,804 KB
testcase_01 AC 41 ms
53,512 KB
testcase_02 AC 153 ms
76,168 KB
testcase_03 AC 73 ms
76,168 KB
testcase_04 AC 115 ms
76,172 KB
testcase_05 AC 111 ms
76,168 KB
testcase_06 AC 134 ms
76,168 KB
testcase_07 AC 80 ms
76,168 KB
testcase_08 AC 109 ms
76,168 KB
testcase_09 AC 111 ms
76,168 KB
testcase_10 AC 188 ms
76,228 KB
testcase_11 AC 73 ms
76,168 KB
testcase_12 AC 125 ms
76,168 KB
testcase_13 AC 103 ms
76,224 KB
testcase_14 AC 150 ms
76,232 KB
testcase_15 AC 127 ms
76,172 KB
testcase_16 AC 140 ms
76,168 KB
testcase_17 AC 171 ms
76,228 KB
testcase_18 AC 86 ms
76,396 KB
testcase_19 AC 203 ms
76,248 KB
testcase_20 AC 81 ms
76,164 KB
testcase_21 AC 159 ms
76,168 KB
testcase_22 AC 127 ms
76,172 KB
testcase_23 AC 488 ms
76,228 KB
testcase_24 AC 449 ms
76,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
N,M=map(int,input().split())
mod=10**9+7
ans=1
if M==1:
	print(1)
	exit()
from collections import Counter
C=Counter([a[1] for a in factorization(M)])

def score(x):
	dp=[0]*(x+1)
	dp[0]=1
	for _ in range(N):
		dp2=[0]*(x+1)
		a=sum(dp)%mod
		for j in range(x+1):
			dp2[j]=a
			a-=dp[x-j]
			a%=mod
		dp=dp2.copy()
	return sum(dp)%mod
	

for c in C:
	ans*=pow(score(c),C[c],mod)
	ans%=mod
print(ans)	
0