N = (p1 ^ x1) * (p2 ^ x2) * ……(pk ^ xk)
约数个数为(x1 + 1) * (x2 + 1) * ……(xk + 1)
约数之和为(1 + p1 + p1 ^ 2 + p1 ^ 3 …… p1 ^ x1) * (1 + p2 + p2 ^ 2…… p2 ^x2)……
先用试除法算出质因数
然后按照公式写出, 废话少说,上代码
C++ 代码
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
int main()
{
int n;
cin >> n;
unordered_map<int, int> primes;
while (n -- )
{
int x;
cin >> x;
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 s : primes)
{
int a = s.first, b = s.second;
LL t = 1;
//第一次t = a + 1, 第二次t = ((a + 1) * a + 1) = a^2 + a + 1
//以此类推
while (b -- ) t = (t * a + 1) % mod;
res = res * t % mod;
}
cout << res;
}