约数和定理:
代码:
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #include <unordered_map> 6 7 using namespace std; 8 9 typedef long long LL; 10 typedef unordered_map<int, int> unmap; 11 12 const int mod = 1e9 + 7; 13 14 unmap prime; 15 16 int main() 17 { 18 int n; 19 scanf("%d", &n); 20 while (n -- ) 21 { 22 int x; 23 scanf("%d", &x); 24 25 for (int i = 2; i <= x / i; i ++ ) 26 while (x % i == 0) 27 { 28 x /= i; 29 prime[i] ++ ; 30 } 31 32 if (x > 1) prime[x] ++ ; 33 } 34 35 LL res = 1; 36 37 for (unmap::iterator it = prime.begin(); it != prime.end(); it ++ ) 38 { 39 LL sum = 1; 40 LL cnt = 1; 41 for (int i = 1; i <= it -> second; i ++ ) 42 { 43 cnt = cnt * it -> first % mod; 44 sum = (sum + cnt) % mod; 45 } 46 res = res * sum % mod; 47 } 48 49 printf("%lld", res); 50 51 return 0; 52 }
原文:https://www.cnblogs.com/wanshu/p/14556695.html