摘要:
题意:给出,m和k,求第k个与m互质的数。m (1 <= m <= 1000000), K (1 <= K <= 100000000).思路:容斥+二分,很巧妙的方法。题目链接:http://poj.org/problem?id=2773View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cmath> 5 #include <cstring> 6 #include <string> 阅读全文
posted @ 2012-10-11 19:20
Hug_Sea
阅读(197)
评论(0)
推荐(0)
摘要:
题意:就是给定一个坐标(n,m),求(1,1)到(n,m)区间内x与y互质的坐标数。思路:利用容斥从2到n,遍历与m互质的个数。题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2841View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstdlib> 5 #include <cstring> 6 #include <string> 7 #include <a 阅读全文
posted @ 2012-10-11 10:56
Hug_Sea
阅读(203)
评论(0)
推荐(0)
摘要:
题意:给出n个数,问找出4个数满足4个数最大公约数为1,最多有多少组。思路:容斥原理,遍历每个数的素因子,奇数个加偶数个减,然后C(n,4)-sum。题目链接:http://poj.org/problem?id=3904View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstdlib> 5 #include <cstring> 6 #include <string> 7 using namespace std 阅读全文
posted @ 2012-10-11 10:41
Hug_Sea
阅读(219)
评论(0)
推荐(0)
浙公网安备 33010602011771号