Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*If you calculate the expected value for a given n with k = 1 (one step), you see that the answer is simply σ1(n) / σ0(n), where σ1(n) denotes the sum of divisors of n and σ0(n) the number of divisors.
- It's well known that σ1 and σ0 are multiplicative functions (and easy to prove indeed). So, it's easy to see from there using induction that the function is multiplicative.*/
- // why they are multiplicative ?
- //coz https://cp-algorithms.com/algebra/divisors.html
- ll dp[55][N];
- ll yo(ll v,ll p,ll k)
- {
- if(k==0) return qpow(v,p)%mod;
- ll &ret=dp[p][k];
- if(ret!=-1) return ret;
- ll ans=0;
- for(ll i=0;i<=p;i++) ans=(ans+yo(v,i,k-1))%mod;
- ans=ans*qpow(p+1,mod-2)%mod;
- return ret=ans;
- }
- int main()
- {
- BeatMeScanf;
- ll i,j,k,n,m;
- vpll fac;
- cin>>n>>k;
- for(i=2;i*i<=n;i++){
- if(n%i==0){
- ll p=0;
- while(n%i==0) n/=i,p++;
- fac.eb(i,p);
- }
- }
- if(n>1) fac.eb(n,1);
- ll ans=1;
- for(auto x:fac){
- mem(dp,-1);
- ans=ans*yo(x.F,x.S,k)%mod;
- }
- cout<<ans<<nl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement