結果

問題 No.1659 Product of Divisors
ユーザー ntudantuda
提出日時 2021-08-29 15:02:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 882 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 152,320 KB
最終ジャッジ日時 2024-11-22 05:44:37
合計ジャッジ時間 20,326 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
57,472 KB
testcase_01 AC 45 ms
132,352 KB
testcase_02 AC 41 ms
57,600 KB
testcase_03 AC 42 ms
127,232 KB
testcase_04 TLE -
testcase_05 AC 304 ms
152,320 KB
testcase_06 AC 45 ms
62,720 KB
testcase_07 AC 44 ms
132,096 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 47 ms
62,592 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 39 ms
51,840 KB
testcase_14 TLE -
testcase_15 AC 44 ms
57,600 KB
testcase_16 AC 41 ms
57,728 KB
testcase_17 AC 42 ms
57,088 KB
testcase_18 AC 47 ms
59,776 KB
testcase_19 AC 42 ms
52,352 KB
testcase_20 AC 44 ms
57,600 KB
testcase_21 AC 43 ms
57,344 KB
testcase_22 AC 45 ms
57,088 KB
testcase_23 AC 48 ms
60,160 KB
testcase_24 AC 45 ms
133,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools, math, sys
mod = 10 ** 9 + 7
N,K = map(int,input().split())

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

P = prime_factorize(N)
NP = len(P)
P = P + [1] * NP
# nCk (mod MOD) を求める
def comb(n, k):
    tmp = 1
    for i in range(k):
        tmp = (tmp * (n - i) * pow(i+1, mod-2, mod)) % mod
    return tmp

Y = set(itertools.combinations(P,NP))
ans = 0
for y in Y:
    dic = {}
    for i in y:
        if i > 1:
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
    tmp = 1
    for k,v in dic.items():
        tmp = tmp * comb(K+v-1,v) % mod
    ans += tmp
    ans %= mod
print(ans)
0