結果

問題 No.1659 Product of Divisors
ユーザー shinichishinichi
提出日時 2021-08-27 22:13:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,298 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 77,640 KB
最終ジャッジ日時 2023-08-13 09:15:17
合計ジャッジ時間 4,598 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
77,160 KB
testcase_01 AC 107 ms
77,360 KB
testcase_02 AC 105 ms
77,116 KB
testcase_03 AC 104 ms
77,164 KB
testcase_04 AC 103 ms
76,892 KB
testcase_05 AC 104 ms
77,192 KB
testcase_06 AC 103 ms
77,240 KB
testcase_07 AC 105 ms
77,136 KB
testcase_08 AC 102 ms
77,368 KB
testcase_09 AC 103 ms
77,472 KB
testcase_10 AC 106 ms
77,148 KB
testcase_11 AC 103 ms
77,368 KB
testcase_12 AC 104 ms
77,476 KB
testcase_13 AC 103 ms
76,920 KB
testcase_14 AC 102 ms
77,476 KB
testcase_15 AC 101 ms
77,364 KB
testcase_16 AC 106 ms
77,372 KB
testcase_17 AC 101 ms
77,368 KB
testcase_18 AC 102 ms
77,584 KB
testcase_19 AC 101 ms
77,348 KB
testcase_20 AC 105 ms
77,376 KB
testcase_21 AC 106 ms
77,472 KB
testcase_22 AC 104 ms
77,240 KB
testcase_23 AC 104 ms
77,640 KB
testcase_24 AC 104 ms
77,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter



def prime_factorize(n):
    primes = []
    while not n % 2:
        primes.append(2)
        n //= 2
    while not n % 3:
        primes.append(3)
        n //= 3
    for p in range(5, int(n**0.5)+1, 6):
        while not n % p:
            primes.append(p)
            n //= p
        while not n % (p+2):
            primes.append(p+2)
            n //= (p+2)
    if n != 1:
        primes.append(n)
    return primes

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
factors = Counter(prime_factorize(N))
ans, MOD = 1, 10**9+7
for key, value in factors.items():
    tmp = 0
    for i in range(value+1):
        tmptmp = 1
        for k in range(K-1+i, K-1, -1):
            tmptmp *= k
            tmptmp %= mod
        tmp += tmptmp*g2[i] if i != 0 else 1
        tmp %= mod
    ans *= tmp
    ans %= mod
print(ans)
0