约数之和(约数)
题
给定 n 个正整数 ai,请你输出这些数的乘积的约数之和,答案对 10^9+7 取模。
输入格式
第一行包含整数 n。
接下来 n 行,每行包含一个整数 ai。
输出格式
输出一个整数,表示所给正整数的乘积的约数之和,答案需对 109+7109+7 取模。
数据范围
1≤n≤100,
1≤ai≤2×10^9
输入样例:
3
2
6
8
输出样例:
252
题解
#includeusing namespace std;const int MOD = 1e9 + 7;
typedef long long LL;int main(){unordered_map 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;
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
