约数个数
有\(n(n<=100)\)个数x\((int范围内)\), 输出这些数的乘积的约数个数.
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
# include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
const int MOD = 1e9 + 7;
int main() {
IOS;
int n;
cin >> n;
while (n -- ) {
int x;
cin >> x;
for (int i = 2; i <= x / i; ++i) {
while (x % i == 0) {
x /= i;
mp[i] ++;
}
}
if (x > 1) {
mp[x] ++;
}
}
long long ans = 1;
for (auto i: mp) {
ans = ans * (1 + i.second) % MOD;
}
cout << ans << '\n';
}
标签:约数,int,个数,cin,mp,ans,一题 From: https://www.cnblogs.com/whose-dream/p/16965011.html试除法分解因数, 且这样分解到的一定是质因子, 对每种质因数的数量利用乘法原理得到答案.