結果

問題 No.1973 Divisor Sequence
ユーザー tktk_snsntktk_snsn
提出日時 2022-06-10 21:49:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,180 KB
最終ジャッジ日時 2024-09-21 07:28:47
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


@lru_cache(None)
def solve(N, d):
    dp = [1] * (d + 1)
    for _ in range(N-1):
        ndp = [0] * (d + 1)
        add = 0
        for i in range(d + 1):
            add += dp[i]
            add %= mod
            ndp[d - i] += add
            ndp[d - i] %= mod
        dp = ndp
    return sum(dp) % mod


N, M = map(int, input().split())
mod = 10 ** 9 + 7
ans = 1
for p, f in prime_factorization(M):
    ans = ans * solve(N, f) % mod
print(ans)
0