結果

問題 No.1659 Product of Divisors
ユーザー ygd.ygd.
提出日時 2021-08-29 10:56:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 723 ms / 2,000 ms
コード長 1,506 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-05-01 21:32:46
合計ジャッジ時間 3,900 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,224 KB
testcase_01 AC 39 ms
57,856 KB
testcase_02 AC 37 ms
52,352 KB
testcase_03 AC 36 ms
52,480 KB
testcase_04 AC 83 ms
58,496 KB
testcase_05 AC 212 ms
76,376 KB
testcase_06 AC 41 ms
59,520 KB
testcase_07 AC 37 ms
58,740 KB
testcase_08 AC 127 ms
60,784 KB
testcase_09 AC 131 ms
61,692 KB
testcase_10 AC 72 ms
58,384 KB
testcase_11 AC 133 ms
60,368 KB
testcase_12 AC 711 ms
76,124 KB
testcase_13 AC 36 ms
51,712 KB
testcase_14 AC 723 ms
76,416 KB
testcase_15 AC 37 ms
57,976 KB
testcase_16 AC 36 ms
58,248 KB
testcase_17 AC 37 ms
58,608 KB
testcase_18 AC 39 ms
59,052 KB
testcase_19 AC 38 ms
58,596 KB
testcase_20 AC 59 ms
58,444 KB
testcase_21 AC 55 ms
59,520 KB
testcase_22 AC 53 ms
58,540 KB
testcase_23 AC 102 ms
59,336 KB
testcase_24 AC 54 ms
58,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

#ルートNまでひたすら割っていく。奇数だけにしても良いか。
#100000
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==[]: #1の場合はここ
        arr.append([n, 1])
 
    return arr

def main():
    n,k= map(int,input().split()); MOD = pow(10,9) + 7
    L = make_divisors(n)
    ans = 0
    for x in L:
        if x == 1:
            ans += 1
            continue
        PL = factorization(x)
        temp = 1
        for val,cnt in PL: #cntをどう分けるか
            temp *= cmb_big(cnt+k-1,k-1,MOD)
            temp %= MOD
        ans += temp
        ans %= MOD
    print(ans)

def cmb_big(x,y,MOD): #xが小さくてyが大きいとき
    y = min(y, x - y)
    ret = 1
    for i in range(y):
        ret = ret*(x-i)*pow(i+1,MOD-2,MOD)
        ret %= MOD
    return ret

if __name__ == "__main__":
    main()
0