如果 N = p1^c1 * p2^c2 * … *pk^ck(p为质因子)
N的约数个数:(c1 + 1) * (c2 + 1) * … * (ck + 1)
N的约数之和:(p1^0 + p1^1 + … + p1^c1) * … * (pk^0 + pk^1 + … + pk^ck)
最大公约数
辗转相除法
O(logn)
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
更相减损术
O(n)
int gcd_sub(int a, int b)
{
if (a < b)
{
swap(a, b);
}
if (b == 1)
{
return a;
}
return gcd_sub(b, a / b);
}
最小公倍数
O(logn)
int lcm(int a, int b)
{
return (ll)a * b / gcd(a, b);
}
n个数乘积的约数个数
unordered_map<int, int> primes;
int main()
{
std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
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 prime : primes)
{
res = res * (prime.second + 1) % 1000000007;
}
cout << res << endl;
return 0;
}
n个数的乘积的约数之和
unordered_map<int, int> primes;
void divide(int x)
{
for (int i = 2; i <= x / i; i++)
{
if (x % i == 0)
{
while (x % i == 0)
{
x /= i;
primes[i]++;
}
}
}
if (x > 1)
{
primes[x]++;
}
}
int main()
{
std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int x;
cin>>x;
divide(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;
}
cout<<res<<endl;
return 0;
}