結果

問題 No.1659 Product of Divisors
ユーザー lloyzlloyz
提出日時 2021-12-11 15:12:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,692 KB
最終ジャッジ日時 2023-09-27 02:49:20
合計ジャッジ時間 3,977 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,576 KB
testcase_01 AC 20 ms
8,692 KB
testcase_02 AC 19 ms
8,556 KB
testcase_03 AC 18 ms
8,544 KB
testcase_04 AC 110 ms
8,632 KB
testcase_05 AC 69 ms
8,632 KB
testcase_06 AC 22 ms
8,544 KB
testcase_07 AC 22 ms
8,544 KB
testcase_08 AC 138 ms
8,636 KB
testcase_09 AC 133 ms
8,652 KB
testcase_10 AC 147 ms
8,672 KB
testcase_11 AC 141 ms
8,520 KB
testcase_12 AC 138 ms
8,656 KB
testcase_13 AC 19 ms
8,568 KB
testcase_14 AC 129 ms
8,648 KB
testcase_15 AC 23 ms
8,520 KB
testcase_16 AC 22 ms
8,564 KB
testcase_17 AC 23 ms
8,632 KB
testcase_18 AC 22 ms
8,572 KB
testcase_19 AC 20 ms
8,656 KB
testcase_20 AC 87 ms
8,564 KB
testcase_21 AC 116 ms
8,524 KB
testcase_22 AC 112 ms
8,560 KB
testcase_23 AC 119 ms
8,548 KB
testcase_24 AC 81 ms
8,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n, k = map(int, input().split())
mod = 10**9 + 7

inv = [1] * 41
for i in range(2, 41):
    inv[i] = mod - inv[mod % i] * (mod // i) % mod

def comb(x, y):
    cnt = 1
    for i in range(y):
        cnt *= (x - i)
        cnt %= mod
        cnt *= inv[i + 1]
        cnt %= mod
    return cnt

nc = n
prime_cnt = defaultdict(int)
while nc % 2 == 0:
    nc //= 2
    prime_cnt[2] += 1
f = 3
while f * f <= n:
    while nc % f == 0:
        nc //= f
        prime_cnt[f] += 1
    f += 2
if nc != 1:
    prime_cnt[nc] += 1

ans = 1
for cnt in prime_cnt.values():
    ans *= comb(k + cnt, cnt)
    ans %= mod
print(ans)

0