2017年8月14日

spoj7001 Visible Lattice Points 莫比乌斯反演+三维空间互质对数

摘要: /** 题目:Visible Lattice Points 链接:https://vjudge.net/contest/178455#problem/A 题意:一个n*n*n大小的三维空间。一侧为(0,0,0)另一侧为(n,n,n); 问从(0,0,0)出发的经过该范围三维空间内整数点坐标的射线有多少条。 思路: 类比二维的:求1 #include #include #include #... 阅读全文

posted @ 2017-08-14 22:49 hnust_accqx 阅读(159) 评论(0) 推荐(0) 编辑

hdu1695 GCD 莫比乌斯反演做法+枚举除法的取值 (5,7),(7,5)看做同一对

摘要: /** 题目:hdu1695 GCD 链接:http://acm.hdu.edu.cn/status.php 题意:对于给出的 n 个询问,每次求有多少个数对 (x,y) , 满足 a ≤ x ≤ b , c ≤ y ≤ d ,且 gcd(x,y) = k ,(5,7),(7,5)看做同一对, gcd(x,y) 函数为 x 和 y 的最大公约数。 本题默认:a = c = 1; 0 #inc... 阅读全文

posted @ 2017-08-14 21:45 hnust_accqx 阅读(136) 评论(0) 推荐(0) 编辑

bzoj2440 完全平方数 莫比乌斯值+容斥+二分

摘要: 莫比乌斯值+容斥+二分 /** 题目:bzoj2440 完全平方数 链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2440 题意:求第k个小x数。小x数是指不存在某个素因子次数>=2。1也是小x数。 思路:二分x,求[1,x]有多少个小x数。如果一个数是某个素数的平方的倍数,那么不是小x数。 所以要减去。2^2的倍数, 3^2的倍数, ... 阅读全文

posted @ 2017-08-14 20:58 hnust_accqx 阅读(140) 评论(0) 推荐(0) 编辑

Problem b 莫比乌斯反演+枚举除法的取值

摘要: 莫比乌斯反演+枚举除法的取值 第二种形式: f(n)表示gcd(x,y)=n的数量。 F(n)表示gcd(x,y)是n的倍数的数量。 /** 题目:Problem b 链接:https://vjudge.net/contest/178455#problem/G 题意:对于给出的 n 个询问,每次求有多少个数对 (x,y) , 满足 a ≤ x ≤ b , c ≤ y ≤ d ,且 gcd(x,y... 阅读全文

posted @ 2017-08-14 20:58 hnust_accqx 阅读(129) 评论(0) 推荐(0) 编辑

Codeforces839D Winter is here 容斥

摘要: /** 题目:Codeforces839D Winter is here 链接:http://codeforces.com/contest/839/problem/D 题意:给定n个数,求所有的最大公约数>1的子集的贡献之和。 一个子集的贡献为最大公约数*子集大小 思路: cnt[i]表示约数为i的数的个数。 ans[i]表示约数为i的所有k的和。 已知ans[i]可以求得贡献为i*ans[i... 阅读全文

posted @ 2017-08-14 11:41 hnust_accqx 阅读(103) 评论(0) 推荐(0) 编辑

hdu6053 TrickGCD 容斥原理

摘要: /** 题目:hdu6053 TrickGCD 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6053 题意:You are given an array A , and Zhu wants to know there are how many different array B satisfy the following conditions? *... 阅读全文

posted @ 2017-08-14 09:35 hnust_accqx 阅读(124) 评论(0) 推荐(0) 编辑

导航