結果

問題 No.1973 Divisor Sequence
ユーザー roarisroaris
提出日時 2022-06-11 20:39:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 75,868 KB
最終ジャッジ日時 2023-10-22 05:47:26
合計ジャッジ時間 5,102 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,656 KB
testcase_01 AC 39 ms
53,428 KB
testcase_02 AC 215 ms
75,740 KB
testcase_03 AC 74 ms
75,844 KB
testcase_04 AC 160 ms
75,732 KB
testcase_05 AC 86 ms
75,656 KB
testcase_06 AC 159 ms
75,740 KB
testcase_07 AC 86 ms
75,724 KB
testcase_08 AC 121 ms
75,732 KB
testcase_09 AC 144 ms
75,732 KB
testcase_10 AC 177 ms
75,860 KB
testcase_11 AC 82 ms
75,724 KB
testcase_12 AC 145 ms
75,732 KB
testcase_13 AC 90 ms
75,856 KB
testcase_14 AC 146 ms
75,808 KB
testcase_15 AC 196 ms
75,736 KB
testcase_16 AC 195 ms
75,736 KB
testcase_17 AC 162 ms
75,860 KB
testcase_18 AC 81 ms
75,728 KB
testcase_19 AC 194 ms
75,868 KB
testcase_20 AC 92 ms
75,728 KB
testcase_21 AC 184 ms
75,736 KB
testcase_22 AC 171 ms
75,732 KB
testcase_23 AC 405 ms
75,664 KB
testcase_24 AC 445 ms
75,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorize(n):
    fct = []
    
    for i in range(2, int(n**0.5)+1):
        c = 0
        
        while n%i==0:
            n //= i
            c += 1
            
        if c>0:
            fct.append((i, c))
    
    if n>1:
        fct.append((n, 1))
    
    return fct

N, M = map(int, input().split())
ans = 1
MOD = 10**9+7

for _, c in factorize(M):
    dp = [0]*(c+1)
    dp[0] = 1
    
    for i in range(N):
        acc = [0]
        
        for j in range(c+1):
            acc.append((acc[-1]+dp[j])%MOD)
            
        ndp = [0]*(c+1)
        
        for j in range(c+1):
            ndp[j] = acc[c-j+1]
    
        dp = ndp

    ans *= sum(dp)%MOD
    ans %= MOD

print(ans)
0