結果

問題 No.1659 Product of Divisors
ユーザー shinichishinichi
提出日時 2021-08-27 22:13:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,298 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 64,952 KB
最終ジャッジ日時 2024-05-01 02:50:45
合計ジャッジ時間 2,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
63,796 KB
testcase_01 AC 44 ms
64,292 KB
testcase_02 AC 44 ms
63,932 KB
testcase_03 AC 51 ms
63,236 KB
testcase_04 AC 43 ms
63,284 KB
testcase_05 AC 45 ms
64,452 KB
testcase_06 AC 42 ms
63,740 KB
testcase_07 AC 44 ms
63,924 KB
testcase_08 AC 44 ms
64,352 KB
testcase_09 AC 46 ms
63,644 KB
testcase_10 AC 47 ms
63,728 KB
testcase_11 AC 46 ms
64,620 KB
testcase_12 AC 45 ms
63,512 KB
testcase_13 AC 44 ms
63,844 KB
testcase_14 AC 44 ms
63,800 KB
testcase_15 AC 46 ms
64,952 KB
testcase_16 AC 46 ms
64,740 KB
testcase_17 AC 46 ms
64,676 KB
testcase_18 AC 52 ms
63,232 KB
testcase_19 AC 46 ms
64,156 KB
testcase_20 AC 47 ms
64,452 KB
testcase_21 AC 49 ms
64,776 KB
testcase_22 AC 47 ms
64,008 KB
testcase_23 AC 46 ms
64,060 KB
testcase_24 AC 47 ms
63,588 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