AcWing 870. 约数个数
原题链接
简单
作者:
术
,
2021-01-31 15:34:35
,
所有人可见
,
阅读 345
注意使用longlong
#include <iostream>
#include <unordered_map>
using namespace std;
const int mod=1e9+7;
int main()
{
int n;
unordered_map<int,int> primes;
cin>>n;
while(n--){
int x;
cin>>x;
for(int i=2;i<=x/i;i++){//分解质因数
if(x%i==0){
while(x%i==0){
primes[i]++;
x/=i;
}
}
}
if(x>1) primes[x]++;
}
unordered_map<int,int>::iterator it;
long long res=1;//这里使用longlong
for(it=primes.begin();it!=primes.end();it++){
int p=it->first,a=it->second;
res=res*(a+1)%mod;
}
cout<<res;
return 0;
}