結果

問題 No.1659 Product of Divisors
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-08-27 22:40:28
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,387 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 100,144 KB
最終ジャッジ日時 2024-05-01 03:25:24
合計ジャッジ時間 3,384 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
92,924 KB
testcase_01 AC 83 ms
92,016 KB
testcase_02 AC 82 ms
91,504 KB
testcase_03 AC 85 ms
91,864 KB
testcase_04 AC 81 ms
91,596 KB
testcase_05 AC 82 ms
91,524 KB
testcase_06 AC 81 ms
92,116 KB
testcase_07 AC 83 ms
91,756 KB
testcase_08 AC 80 ms
92,164 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 82 ms
91,648 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter


def prime_factorize(n: int) -> list:
    res = []

    while n % 2 == 0:
        res.append(2)
        n //= 2

    f = 3

    while f ** 2 <= n:
        if n % f == 0:
            res.append(f)
            n //= f
        else:
            f += 2

    if n != 1:
        res.append(n)

    return res

mod = 10 ** 9 + 7
class Combinatorics:
    def __init__(self, n: int) -> None:
        self.n = n
        self.fa = [1] * (self.n * 2 + 1)
        self.fi = [1] * (self.n * 2 + 1)

        for i in range(1, self.n * 2 + 1):
            self.fa[i] = self.fa[i - 1] * i % mod

        self.fi[-1] = pow(self.fa[-1], mod - 2, mod)

        for i in range(self.n * 2, 0, -1):
            self.fi[i - 1] = self.fi[i] * i % mod

    def comb(self, n: int, r: int) -> int:
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod

    def perm(self, n: int, r: int) -> int:
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[n - r] % mod
        
    def combr(self, n: int, r: int) -> int:
        if n == r == 0:return 1
        return self.comb(n + r - 1, r)

C = Combinatorics(10 ** 6)
n, k = map(int, input().split())
c = Counter(prime_factorize(n))
ans = 1
for _, v in c.items():
    ans *= C.comb(k + v, k)
    ans %= mod
print(ans)
0