AcWing 871. 约数之和
原题链接
简单
作者:
我要出去乱说
,
2021-01-18 10:35:37
,
所有人可见
,
阅读 270
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
int main()
{
int n;
scanf("%d", &n);
unordered_map<int, int> primes;
while (n -- )
{
int x;
scanf("%d", &x);
//约数个数等于质因数分解后各个底数从0到α之和之积
for (int i = 2; i <= x / i; i ++ )
while (x % i == 0)
{
x /= i;
primes[i] ++ ;
}
if (x > 1) primes[x] ++ ;
}
LL res = 1;
for (auto prime : primes)
{
int p = prime.first, a = prime.second;
LL t = 1;
while (a -- ) t = (t * p + 1) % mod; //类似秦九韶算法
res = res * t % mod;
}
printf("%d\n", res);
return 0;
}