https://oj.neu.edu.cn/problem/1460
Thinking: If n = (p1 ^ a1) * (p2 ^ a2) ... (pn ^ an), then f (n, 0) = a1 * a2 * ... * an, obviously f (n, 0) it is a multiplicative function for f (x, y) we can see that he is f (x, y-1) Dirichlet convolution results obtained with itself, so that f (x, y) is also a multiplicative function. Thus, as long as the quality of factoring n, then the value of dp can be pre-sort and power. Note concepts multiplicative function of a, b must be coprime!
#include<bits/stdc++.h> #define int long long using namespace std; const int mod = 1000000007; maxn const int = 1000000 + 5, MaxM = 10000 + 5; int dp[30][maxm]; vector<int> g[maxn]; inline void solve(int n){ int nn = n; for(int i=2;i*i<=n;i++){ if(n%i==0){ int num = 0; while(n%i==0) n/=i,num++; g[nn].push_back(num); } } if(n>1) g[nn].push_back(1); } void init(int n=30,int m=maxm){ for(int i=1;i<n;i++) dp[i][0] = i; for(int i=1;i<n;i++){ for(int j=1;j<m;j++){ if(i==1){ dp[i][j] = dp[i][j-1]*2%mod; } else { dp[i][j] = dp[i][j-1]*2%mod; for(int k=1;k<i;k++){ dp[i][j] = (dp[i][j] + dp[k][j - 1] * dp[i - k][j - 1] % mod) % mod; } } } } } signed main(){ ios::sync_with_stdio(0); cin.tie (0); cout.tie (0); init(); int t; cin>>t; while(t--){ int n,m; cin>>n>>m; if(n==1) cout<<1<<endl; else{ if(g[n].size()==0) solve(n); int year = 1; for(int i=0;i<g[n].size();i++){ ans = ans*dp[g[n][i]][m]%mod; } cout<<ans<<endl; } } return 0; }