N = (p1^x1)(p^x2)(p3^x3)…(pk^xk),其中pi为质数。N的约数个数为(x1 + 1)(x2 + 1)~~(xk + 1)
unordered_map primes; 它存储键值对,其中键是唯一的。
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)
res = (LL)res * (s.second + 1) % mod;
cout << res;
}