D. Makoto and a Blackboard
time limit per test 2 seconds
memory limit per test 256 megabytes
inputstandard input
outputstandard output
Makoto has a big blackboard with a positive integer n written on it. He will perform the following action exactly k times:
Suppose the number currently written on the blackboard is v. He will randomly pick one of the divisors of v (possibly 1 and v) and replace v with this divisor. As Makoto uses his famous random number generator (RNG) and as he always uses 58 as his generator seed, each divisor is guaranteed to be chosen with equal probability.
He now wonders what is the expected value of the number written on the blackboard after k steps.
It can be shown that this value can be represented as where P and Q are coprime integers and . Print the value of modulo .
Input
The only line of the input contains two integers n and k
.
Output
Print a single integer — the expected value of the number on the blackboard after k steps as
for P, Q defined above.
Examples
input
6 1
output
3
input
6 2
output
875000008
input
60 5
output
237178099
Note
In the first example, after one step, the number written on the blackboard is 1, 2, 3 or 6 — each occurring with equal probability. Hence, the answer is
.
In the second example, the answer is equal to
思路:n分解为素因子相乘形式为
。经过k次变换后就相当于是
发生了变化。
可以发现素因子之间并没有相互影响,可以单独求出
的概率,然后求出
对于结果的期望贡献,然后累乘。
对于
,
表示经过
次变换后
的幂
的概率,那么
的期望贡献为
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e4+10;
const int MOD=1e9+7;
typedef long long ll;
ll d[MAX][65],inv[MAX];
ll n,m;
ll solve(ll x,ll y)
{
ll sum=0,now=1;
memset(d,0,sizeof d);
d[0][y]=1;
for(ll i=0;i<m;i++)
{
for(ll j=0;j<=y;j++)
{
if(d[i][j])
{
for(ll k=0;k<=j;k++)d[i+1][k]=(d[i+1][k]+d[i][j]*inv[j+1])%MOD;
}
}
}
for(ll i=0;i<=y;i++)
{
sum=(sum+now*d[m][i])%MOD;
now=now*x%MOD;
}
return sum;
}
int main()
{
inv[1]=1;
for(int i=2;i<=2000;i++)inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
ll ans=1;
cin>>n>>m;
for(ll i=2;i*i<=n;i++)
{
if(n%i)continue;
int cnt=0;
while(n%i==0)n/=i,cnt++;
ans=ans*solve(i,cnt)%MOD;
}
if(n>1)ans=ans*solve(n,1)%MOD;
cout<<ans<<endl;
return 0;
}