結果

問題 No.1659 Product of Divisors
ユーザー tassei903tassei903
提出日時 2021-08-27 22:04:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,359 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 87,404 KB
実行使用メモリ 75,932 KB
最終ジャッジ日時 2023-08-13 09:02:31
合計ジャッジ時間 3,605 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,808 KB
testcase_01 AC 78 ms
75,592 KB
testcase_02 AC 73 ms
71,400 KB
testcase_03 AC 76 ms
71,592 KB
testcase_04 AC 87 ms
75,716 KB
testcase_05 AC 83 ms
75,664 KB
testcase_06 AC 76 ms
75,816 KB
testcase_07 AC 76 ms
75,620 KB
testcase_08 AC 91 ms
75,708 KB
testcase_09 AC 91 ms
75,812 KB
testcase_10 AC 91 ms
75,556 KB
testcase_11 AC 91 ms
75,788 KB
testcase_12 AC 90 ms
75,704 KB
testcase_13 AC 73 ms
71,604 KB
testcase_14 AC 92 ms
75,484 KB
testcase_15 AC 76 ms
75,808 KB
testcase_16 AC 78 ms
75,640 KB
testcase_17 AC 78 ms
75,428 KB
testcase_18 AC 77 ms
75,664 KB
testcase_19 AC 78 ms
75,424 KB
testcase_20 AC 85 ms
75,524 KB
testcase_21 AC 89 ms
75,428 KB
testcase_22 AC 88 ms
75,520 KB
testcase_23 AC 89 ms
75,932 KB
testcase_24 AC 84 ms
75,620 KB
権限があれば一括ダウンロードができます

ソースコード

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