http://acm.hdu.edu.cn/showproblem.php?pid=1215 题意:求解小于n的所有因子和 利用数论的唯一分解定理. 若n = p1^e1 * p2^e2 * ……*pn^en(任何一个数都可以分解成素数乘积) 则n的因子个数为  (1+e1)(1+e2)……(1+en) n的各个因子的和为(1+p1+p1^2+……+p1^e1)(1+p2+p2^2+……+p2^e2)……(1+pn+pn^2+……+pn^en) (把式子化简就知道为什么了) ac代码: #inc…
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. Now given a humble number, please write a program t…
http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意: 思路: 根据唯一分解定理,$n={a_{1}}^{p1}*{a2_{}}^{p2}...*{a_{m}}^{pm}$,那么n的因子数就是 n的k次方也是一样的,也就是p前面乘个k就可以了. 先打个1e6范围的素数表,然后枚举每个素数,在[ l , r ]寻找该素数的倍数,将其分解质因数. 到最后如果一个数没有变成1,那就说明这个数是大于1e6的质数.(它就只有0和1两种选择) #include<…
一行代表一个数 x 给你底数和指数 求x-1的唯一分解定理的底数和指数 从大到小输出 #include<stdio.h> #include<string.h> #include<algorithm> #include<vector> #include<math.h> using namespace std; #define MAXN 100010 double z[MAXN],x[MAXN]; bool pri[MAXN]; int p[MAXN…
题目链接:https://cn.vjudge.net/problem/HDU-1215 题意 中文题,自己去看吧,懒得写:) 思路 \[ Ans=\prod \sum p_i^j \] 唯一分解定理 关键在于求因子了,模版到时候整理 提交过程 AC 代码 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int factors[200][2], fsize; vo…
题目链接 题意:输入两个整数L,U(L <= U <= 1000000000, u - l <= 10000),统计区间[L,U]的整数中哪一个的正约数最多,多个输出最小的那个 本来想着用欧拉函数,打个表求所有的约数个数,但是u太大,直接暴力求解 利用唯一分解定理,刷选出根号1000000000的素数,对l,u区间的每一个数进行分解 #include <iostream> #include <cstdio> #include <algorithm> #…
题目链接:传送门 题意: 求2004^x的全部约数的和. 分析: 由唯一分解定理可知 x=p1^a1*p2^a2*...*pn^an 那么其约数和 sum = (p1^0+p1^1^-+p1^a1)*-* (pn^0+pn^1^-+pn ) 代码例如以下: #include <iostream> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; con…
Sumdiv Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1845 Appoint description:   System Crawler  (2015-05-27) Description Consider two natural numbers A and B. Let S be the sum of all natural…
题目链接 首先介绍两个定理. 整数唯一分解定理:任意正整数都有且只有一种方式写出素数因子的乘积表达式. \(A=(p1k1 p2k2 ...... pnkn \) 求这些因子的代码如下 ;i*i<=a;++i){ if(!(a%i)){ prime[++num]=i; while(!(a%i)){ a/=i; sum[num]++; } } } ){ prime[++num]=a; sum[num]=; } 唯一分解定理 约数和公式:对于已经分解的整数A,有A的所有因子和为 \( S= (1+p…
Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17387   Accepted: 4374 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 99…