https://codeforces.com/problemset/problem/1097/D
【题意】
给定一个数n,可以进行k次操作,每次操作将数变成它的因子,问期望是多少
【思路】
补充:为什么是积性函数呢?,类似于打表吧。。会发现f(6)=f(2)*f(3)
哈!又知道一种找规律的方法!!!
【代码】
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll maxn = 1e4 + 5;
const ll MOD = 1e9 + 7;;
ll a[maxn];
ll inv[maxn];
ll ans = 0;void init() {inv[1] = 1;for (ll i = 2; i <= 1000; i++) {inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;;}
}ll n, k;
ll dp[maxn][103];//dp[i][j]表示第i轮指数为j的方案数ll solve(ll x, ll y) {//求x^y的期望memset(dp, 0, sizeof(dp));dp[0][y] = 1;for (ll i = 0; i < k; i++) {for (ll j = 0; j <= y; j++) {for (ll k = 0; k <= j; k++) {dp[i + 1][k] = (dp[i + 1][k] + dp[i][j] * inv[j + 1]) % MOD;}}}ll now = 1, sum = 0;for (ll i = 0; i <= y; i++) {sum = (sum + now * dp[k][i]) % MOD;now = now * x%MOD;}return sum;
}int main() { while (~scanf("%lld%lld", &n, &k)) {init();ans = 1;for (ll i = 2; i <= sqrt(n); i++) {if (n%i == 0) {ll cnt = 0;while (n%i == 0)cnt++, n /= i;ans = ans * solve(i, cnt) % MOD;}}if(n>1)ans = ans * solve(n, 1) % MOD;printf("%lld\n", ans);}
}