题
给定 n 个正整数 ai,请你输出这些数的乘积的约数之和,答案对 10^9+7 取模。
输入格式
第一行包含整数 n。
接下来 n 行,每行包含一个整数 ai。
输出格式
输出一个整数,表示所给正整数的乘积的约数之和,答案需对 109+7109+7 取模。
数据范围
1≤n≤100,
1≤ai≤2×10^9
输入样例:
3
2
6
8
输出样例:
252
题解
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long LL;
int main(){
unordered_map<int, int> pri; //存质因子指数
int n;
cin >> n;
while(n--){
int x;
cin >> x;
for(int i = 2; i <= x / i; i++){
while(x % i == 0){ //因式分解求质因子指数
x /= i;
pri[i]++;
}
}
if(x > 1)pri[x]++; //特殊处理
}
LL res = 1;
for(auto p : pri){
LL a = p.first, b = p.second;
LL t = 1;
while(b--) t = (t * a + 1) % MOD;//照约数和公式实现
res = res * t % MOD;
}
cout << res << endl;
return 0;
}