結果

問題 No.1973 Divisor Sequence
ユーザー tktk_snsntktk_snsn
提出日時 2022-06-10 21:49:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 456 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,708 KB
実行使用メモリ 76,356 KB
最終ジャッジ日時 2023-10-21 06:19:18
合計ジャッジ時間 3,689 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
55,856 KB
testcase_01 AC 46 ms
55,568 KB
testcase_02 AC 93 ms
76,168 KB
testcase_03 AC 63 ms
72,724 KB
testcase_04 AC 85 ms
76,168 KB
testcase_05 AC 84 ms
76,172 KB
testcase_06 AC 86 ms
76,168 KB
testcase_07 AC 74 ms
76,168 KB
testcase_08 AC 84 ms
76,172 KB
testcase_09 AC 82 ms
76,168 KB
testcase_10 AC 107 ms
76,100 KB
testcase_11 AC 64 ms
72,724 KB
testcase_12 AC 88 ms
76,172 KB
testcase_13 AC 78 ms
76,100 KB
testcase_14 AC 115 ms
76,224 KB
testcase_15 AC 87 ms
76,168 KB
testcase_16 AC 90 ms
76,172 KB
testcase_17 AC 105 ms
76,104 KB
testcase_18 AC 83 ms
76,236 KB
testcase_19 AC 117 ms
76,356 KB
testcase_20 AC 77 ms
76,160 KB
testcase_21 AC 99 ms
76,172 KB
testcase_22 AC 85 ms
76,168 KB
testcase_23 AC 456 ms
76,192 KB
testcase_24 AC 195 ms
76,112 KB
権限があれば一括ダウンロードができます

ソースコード

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