Description As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some prime numbers:      C = p1×p2× p3× ... × pk  which p1, p2 ... pk are all prime numbers.For example, if C = 24, then:      24 = 2 × 2 × 2 × 3      here, p…
/** 题目:hdu4746 Mophues 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4746 题意:求x,y在给定范围内gcd(x,y)分解素因子的个数<=p的对数. (n, m, P <= 5×105. Q <=5000). 思路: f(n)表示给定范围内gcd(x,y)==n的对数. g(n)表示给定范围内gcd(x,y)为n的倍数的对数. f(n) = sigma[n|d]mu[d/n]*g(d) = sigma[n|d]mu[d…
Description Edward has a set of n integers {a1, a2,...,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonempty subset has equal probability to be picked), and would like to know the expectation of [gcd(x1, x2,…,xm)]k. Note that gcd(x1, …
Description Alice is playing a game with Bob. Alice shows N integers a 1, a 2, …, a N, and M, K. She says each integers 1 ≤ a i ≤ M. And now Alice wants to ask for each d = 1 to M, how many different sequences b 1, b 2, …, b N. which satisfies : 1. F…
Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example…
Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large, you're only required to output the total num…
Description 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. Input 一个整数N Output 如题 Sample Input 4 Sample Output 4 Hint 对于样例(2,2),(2,4),(3,3),(4,2) 1<=N<=10^7 这个题目可以用欧拉函数或者莫比乌斯反演. 第一种欧拉函数: 因为gcd(x, y) = p,所以gcd(x/p, y/p) = 1. 不妨设y较大,那么就是求所有比y/p小的数k,ph…
以下以目前遇到题目开始记录,按发布时间排序 ACM之递推递归 ACM之数学题 拓扑排序 ACM之最短路径做题笔记与记录 STL学习笔记不(定期更新) 八皇后问题解题报告…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5512 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是给了初始的集合{a, b},然后取集合里的两个元素进行加或者减的操作,生成新的元素.问最后最多能生成多少个元素.问答案的奇偶性. 首先一开始有a, b.那么如果生成了b-a(b>a),自然原来的数同样可以由b-a, a生成(b != 2a). 于是如此反复下去,最后的数必然是可以由两个数p, 2p生成的. 于是所有的数肯定可以表示成xp+…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5521 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是一个人从1开始走,一个人从n开始走.让最后相遇的时间最短. 题目就是个最短路,不过唯一不同的是,题目图的描述方式比较特别. 从规模上来看,想把这张图描述成邻接矩阵或者邻接表是不可能的. 必然只能按照题目要求的意思来存. 于是第一步存图的方式,我采用了两个vector数组,(当然此处可以使用链式前向星),一个存了和点相关的集合有哪些in[]…