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 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 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…
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 给定整数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…
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 There are n people standing in a line. Each of them has a unique id number. Now the Ragnarok is coming. We should choose 3 people to defend the evil. As a group, the 3 people should be able to communicate. They are able to communicate if…
  时间限制:6000ms 单点时限:1000ms 内存限制:256MB   描述 你在赌场里玩梭哈,已经被发了4张牌,现在你想要知道发下一张牌后你得到顺子的概率是多少? 假定赌场使用的是一副牌,四种花色的A.2.3.....J.Q.K共52张,这副牌只发给你了4张,你的剩下一张牌从剩下48张中任意取出一张. 顺子指的是点数连续的五张牌,包括10.J.Q.K.A这种牌型(不包含同花顺,即构成顺子的五张牌花色不能相同).参见:https://zh.wikipedia.org/wiki/%E6%92…
Description Ray 在数学课上听老师说,任何小数都能表示成分数的形式,他开始了化了起来,很快他就完成了,但他又想到一个问题,如何把一个循环小数化成分数呢? 请你写一个程序不但可以将普通小数化成最简分数,也可以把循环小数化成最简分数.   Input 第一行是一个整数N,表示有多少组数据. 每组数据只有一个纯小数,也就是整数部分为0.小数的位数不超过9位,循环部分用()括起来.   Output 对每一个对应的小数化成最简分数后输出,占一行.   Sample Input 3 0.(4…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695 题意: 给出n.m.k ,求出1<=x<=n, 1<=y<=m 且gcd(x,y) == k 的(x,y)的对数 解析: 显然就是求 [1,n/k] 与 [1, m/k]有多少数对的最大公约数是1 莫比乌斯入门题 我们设 为满足且和的的对数 为满足且和的的对数 那么,很显然,反演后得到 我们所需要的答案便是  f(1) = ∑i=1µ(i)*(n/i)*(m/i)  ,求解这个式…