結果

問題 No.1659 Product of Divisors
ユーザー 👑 H20H20
提出日時 2021-08-27 23:11:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 2,387 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 61,052 KB
最終ジャッジ日時 2024-05-01 04:03:57
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,356 KB
testcase_01 AC 43 ms
59,836 KB
testcase_02 AC 39 ms
54,856 KB
testcase_03 AC 39 ms
55,520 KB
testcase_04 AC 40 ms
55,364 KB
testcase_05 AC 41 ms
55,072 KB
testcase_06 AC 40 ms
56,252 KB
testcase_07 AC 43 ms
59,472 KB
testcase_08 AC 44 ms
54,436 KB
testcase_09 AC 41 ms
54,616 KB
testcase_10 AC 47 ms
60,372 KB
testcase_11 AC 39 ms
54,696 KB
testcase_12 AC 41 ms
55,904 KB
testcase_13 AC 41 ms
54,992 KB
testcase_14 AC 41 ms
55,580 KB
testcase_15 AC 43 ms
60,992 KB
testcase_16 AC 44 ms
60,724 KB
testcase_17 AC 40 ms
55,964 KB
testcase_18 AC 40 ms
55,972 KB
testcase_19 AC 40 ms
55,572 KB
testcase_20 AC 43 ms
61,000 KB
testcase_21 AC 43 ms
61,052 KB
testcase_22 AC 48 ms
59,728 KB
testcase_23 AC 41 ms
54,372 KB
testcase_24 AC 43 ms
60,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

# ModInt 参考は以下のサイト
# https://qiita.com/wotsushi/items/c936838df992b706084c

MOD = 10**9+7
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )



def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N,K = map(int, input().split())
mod = 10**9+7
P = prime_factorize(N)
C = collections.Counter(P)
L = []
for v in C.values():
    L.append(v)
ans = ModInt(1)
for l in L:
    temp = ModInt(1)
    for i in range(1,l+1):
        temp = temp*(K+l+1-i)
        temp = temp/i
    ans = ans*temp
print(ans)
0