1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; /* 思路: 1、分别将a1、a2、a3...an的质因数,求出每个质数的次数 2、求(指数+1)相乘的乘积 */ int n; //哈希表,存储所有的底数和指数 unordered_map<int,int> primes; const int MOD = 1e9 + 7; typedef long long LL; int main() { cin>>n; int x; while(n--){ cin>>x; int i = 2; for(int i = 2;i <= x / i;i++){ while(x % i == 0){ x = x / i; primes[i]++;//质因子i出现的次数+1 } } if(x > 1) primes[x]++;//说明x是一个比较大的质因数 } LL res = 1; unordered_map<int,int>::iterator it; for(it = primes.begin();it != primes.end();it++){ res = res * ((*it).second + 1) % MOD; } cout<<res; return 0; }
- 1
信息
- ID
- 1056
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者