AcWing 871. 约数之和
原题链接
简单
C++ 代码
#include<iostream>
#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> hash;
while(n--)
{
int x;
scanf("%d",&x);
for(int i=2;i<=x/i;i++)
{
if(x%i==0)
{
while(x%i==0)
{
x/=i;
hash[i]++;
}
}
}
if(x>1) hash[x]++;
}
ll res=1;
for(auto prime : hash)
{
int p=prime.first;
int m=prime.second;
ll r=1;
for(int i=1;i<=m;i++)
{
r=(r*p+1) % mod;
}
res=res*r % mod;
}
printf("%lld",res);
}