AcWing 871. 约数之和
原题链接
简单
作者:
噗呲噗呲
,
2020-04-07 21:22:24
,
所有人可见
,
阅读 511
约数之和
#include <iostream>
#include <unordered_map>
using namespace std;
const int mod = 1e9 + 7;
unordered_map<int,int> primes;
void divide(int n){
for(int i = 2; i <= n / i; i ++){
if(n % i == 0){
while(n % i == 0){
n /= i;
primes[i] ++;
}
}
}
if(n > 1) primes[n] ++;
}
int main(){
int n;
cin >> n;
while(n--){
int x;
cin >> x;
divide(x);
}
long long res = 1;
for(unordered_map<int,int>::iterator it = primes.begin(); it != primes.end(); it ++){
int p = it -> first,b = it -> second;
long long t = 1;
while(b--){
t = (t * p + 1) % mod;
}
res = res * t % mod;
}
cout << res << endl;
return 0;
}