约数之和(n个数乘积的约数和

# 题意

n个数,求出他们的乘积的所有约数之和 mod 1e9+10

# 题解

同样求出每个质因数的指数,根据乘法分配律计算即可

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 const int mod=1e9+7;
 5 unordered_map<int,int >primes;
 6 int main(){
 7     int n;
 8     scanf("%d",&n);
 9 
10     while(n--){
11         int x;
12         scanf("%d",&x);
13         for (int i = 2; i <=x/i ; ++i)
14             while(x%i==0){
15                 x/=i;
16                 primes[i]++;
17             }
18         if(x>1) primes[x]++;
19     }
20     LL res=1;
21     for (auto prime:primes)
22     {
23         int p=prime.first,a=prime.second;
24         LL t=1;
25         while(a--) t=(t*p+1)%mod;
26         res=res*t%mod;
27     }
28     cout<<res<<endl;
29     return 0;
30 }

猜你喜欢

转载自www.cnblogs.com/hhyx/p/12589197.html