郑州网站推广单位,wordpress系统速度慢,上海做网站的月薪,邢台微商城制作设计知识概览
约数个数 基于算数基本定理#xff0c;假设N分解质因数的结果为 可得对于N的任何一个约数d#xff0c;有 因为N的每一个约数和~的一种选法是一一对应的#xff0c;根据乘法原理可得#xff0c; 一个数的约数个数为 约数之和 一个数的约数之和公式为 多项式乘积的…知识概览
约数个数 基于算数基本定理假设N分解质因数的结果为 可得对于N的任何一个约数d有 因为N的每一个约数和~的一种选法是一一对应的根据乘法原理可得 一个数的约数个数为 约数之和 一个数的约数之和公式为 多项式乘积的每一项为 正好对应的是一个数的每一个约数。 例题展示
约数个数
题目链接
活动 - AcWing系统讲解常用算法与数据结构给出相应代码模板并会布置、讲解相应的基础算法题目。https://www.acwing.com/problem/content/872/
代码
#include iostream
#include algorithm
#include unordered_mapusing namespace std;typedef long long LL;const int mod 1e9 7;int main()
{int n;cin n;unordered_mapint, int primes;while (n--){int x;cin x;for (int i 2; i x / i; i)while (x % i 0){x / i;primes[i];}if (x 1) primes[x];}LL res 1;for (auto prime : primes) res res * (prime.second 1) % mod;cout res endl;return 0;
} 约数之和
题目链接
活动 - AcWing系统讲解常用算法与数据结构给出相应代码模板并会布置、讲解相应的基础算法题目。https://www.acwing.com/problem/content/873/
代码
#include iostream
#include algorithm
#include unordered_mapusing namespace std;typedef long long LL;const int mod 1e9 7;int main()
{int n;cin n;unordered_mapint, int primes;while (n--){int x;cin x;for (int i 2; i x / i; i)while (x % i 0){x / i;primes[i];}if (x 1) primes[x];}LL res 1;for (auto prime : primes){int p prime.first, a prime.second;LL t 1;while (a--) t (t * p 1) % mod;res res * t % mod;}cout res endl;return 0;
} 参考资料
AcWing算法基础课