結果

問題 No.1659 Product of Divisors
ユーザー tassei903
提出日時 2021-08-27 22:04:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,359 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 60,204 KB
最終ジャッジ日時 2024-11-21 02:28:24
合計ジャッジ時間 2,130 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################


p = 10 ** 9 + 7
N = 10 ** 3  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
def cmb(n, r):
    res = 1
    for i in range(r):
        res*=n-i
        res%=p
        res*=inv[i+1]
        res%=p
    return res


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n,k = na()
ans = 1
d = factorization(n)
for i, x in d:
    if i==1:
        continue
    #print(x,k)
    ans*=cmb(x+k,x)
    ans%=p
print(ans)
0