結果

問題 No.1659 Product of Divisors
ユーザー raven7959raven7959
提出日時 2021-09-08 10:39:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 89,164 KB
最終ジャッジ日時 2023-08-26 15:28:18
合計ジャッジ時間 5,883 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
88,888 KB
testcase_01 AC 140 ms
88,892 KB
testcase_02 AC 136 ms
89,012 KB
testcase_03 AC 135 ms
89,148 KB
testcase_04 AC 144 ms
89,140 KB
testcase_05 AC 132 ms
88,904 KB
testcase_06 AC 132 ms
88,972 KB
testcase_07 AC 133 ms
88,776 KB
testcase_08 AC 131 ms
88,872 KB
testcase_09 AC 128 ms
88,888 KB
testcase_10 AC 129 ms
88,732 KB
testcase_11 AC 133 ms
88,940 KB
testcase_12 AC 135 ms
88,824 KB
testcase_13 AC 133 ms
88,844 KB
testcase_14 AC 133 ms
89,164 KB
testcase_15 AC 133 ms
89,096 KB
testcase_16 AC 131 ms
89,020 KB
testcase_17 AC 134 ms
89,004 KB
testcase_18 AC 132 ms
88,960 KB
testcase_19 AC 135 ms
88,904 KB
testcase_20 AC 132 ms
88,732 KB
testcase_21 AC 132 ms
88,992 KB
testcase_22 AC 134 ms
88,684 KB
testcase_23 AC 132 ms
89,012 KB
testcase_24 AC 133 ms
88,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=10**6
isprime=[True]*(n+1) #isprime[i]はiが素数かどうか
isprime[0]=False
isprime[1]=False
for p in range(2,n+1):
  if isprime[p]:
    for q in range(2*p,n+1,p):
      isprime[q]=False
P=[i for i in range(10**6) if isprime[i]]

def extgcd(a,b):
  if b:
    d,y,x=extgcd(b,a%b)
    y-=(a//b)*x
    return d,x,y
  return a,1,0
def modinv(a,mod):
  return extgcd(a,mod)[1]

N,K=map(int,input().split())
mod=10**9+7
divs=[]
for p in P:
  exp=0
  while N%p==0:
    exp+=1
    N//=p
  if exp:
    divs.append(exp)
if N>1:
  divs.append(1)
ans=1
for div in divs:
  res=0
  for n in range(div+1):
    c=1
    for i in range(1,n+1):
      c=c*(n+K-i)%mod*modinv(i,mod)%mod
    # print(n,c)
    res+=c
  res%=mod
  ans=ans*res%mod
print(ans)
0