$$\color{red}{算法}\color{blue}{基础课}\color{purple}{笔记and题解}\color{green}{汇总}$$
与 约数个数 思路完全一样。
根据多项式乘法,把每一项换成具体的权值即可。
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
unordered_map<int, int> mp;
int T, x;
int main() {
scanf("%d", &T);
while (T--) {
int x; scanf("%d", &x);
for (int i = 2; i <= x / i; i++) {
if (x % i != 0) continue;
int cnt = 0;
while (x % i == 0) cnt++, x /= i;
mp[i] += cnt;
}
if (x > 1) mp[x]++;
}
long long ans = 1;
for (auto it : mp) {
int cnt = it.second, a = it.first;
long long x = 1, res = 1;
for (int i = 1; i <= cnt; i++) {
(x *= a) %= mod;
(res += x) %= mod;
}
(ans *= res) %= mod;
}
printf("%lld\n", ans);
return 0;
}