結果

問題 No.1659 Product of Divisors
ユーザー tktk_snsntktk_snsn
提出日時 2021-08-27 22:40:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 7,980 KB
最終ジャッジ日時 2023-08-13 09:56:12
合計ジャッジ時間 2,571 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,776 KB
testcase_01 AC 17 ms
7,808 KB
testcase_02 AC 16 ms
7,856 KB
testcase_03 AC 16 ms
7,800 KB
testcase_04 AC 56 ms
7,804 KB
testcase_05 AC 40 ms
7,892 KB
testcase_06 AC 18 ms
7,980 KB
testcase_07 AC 18 ms
7,780 KB
testcase_08 AC 70 ms
7,808 KB
testcase_09 AC 70 ms
7,780 KB
testcase_10 AC 96 ms
7,924 KB
testcase_11 AC 70 ms
7,888 KB
testcase_12 AC 69 ms
7,852 KB
testcase_13 AC 16 ms
7,824 KB
testcase_14 AC 68 ms
7,804 KB
testcase_15 AC 18 ms
7,852 KB
testcase_16 AC 17 ms
7,952 KB
testcase_17 AC 18 ms
7,868 KB
testcase_18 AC 18 ms
7,844 KB
testcase_19 AC 17 ms
7,896 KB
testcase_20 AC 50 ms
7,932 KB
testcase_21 AC 77 ms
7,836 KB
testcase_22 AC 73 ms
7,780 KB
testcase_23 AC 62 ms
7,856 KB
testcase_24 AC 49 ms
7,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def binomial_coefficient(n, r):
    if r < 0 or r > n:
        return 0
    res = 1
    div = 1
    r = min(r, n - r)
    for i in range(r):
        res = res * (n - i) % mod
        div = div * (i + 1) % mod
    return res * pow(div, mod-2, mod) % mod


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


comb = binomial_coefficient
mod = 10 ** 9 + 7
N, K = map(int, input().split())
ans = 1

for p, f in prime_factorization(N):
    ans *= comb(K + f, K)
    ans %= mod
print(ans)
0