結果

問題 No.1659 Product of Divisors
ユーザー brthyyjpbrthyyjp
提出日時 2021-08-29 12:31:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 92,068 KB
最終ジャッジ日時 2024-05-01 21:57:22
合計ジャッジ時間 3,339 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
90,620 KB
testcase_01 AC 65 ms
91,116 KB
testcase_02 WA -
testcase_03 AC 68 ms
90,808 KB
testcase_04 AC 74 ms
90,964 KB
testcase_05 AC 77 ms
91,064 KB
testcase_06 AC 65 ms
91,020 KB
testcase_07 AC 71 ms
90,952 KB
testcase_08 AC 85 ms
90,800 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
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 #

import math
def factorize(n):
    d = {}
    temp = int(math.sqrt(n))+1
    for i in range(2, temp):
        while n%i== 0:
            n //= i
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    if d == {}:
        d[n] = 1
    else:
        if n in d:
            d[n] += 1
        elif n != 1:
            d[n] =1
    return d

N = 10**6
mod = 10**9+7
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod

n, k = map(int, input().split())
D = factorize(n)
ans = 1
for p, q in D.items():
    ans *= cmb1(q+k, k, mod)
    ans %= mod
print(ans)
0