容斥
GoneWithTheWind_yin
山科大学生
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
完全平方数 BZOJ - 2440
题目传送门思路:这个题要求的是第K个非完全平方数且没有完全平方数因子的数,我们可以将这个问题转换为求这个区间的所有完全平方数且没有完全平方数因子的数的数量,这样就可以通过二分的方法来求解,具体的数量的可以通过容斥原理来求得,而此时可以用到莫比乌斯函数来做为系数。#include <algorithm> #include <cmath> #include <cstdio> #include <cstr原创 2017-10-16 09:25:16 · 581 阅读 · 0 评论 -
能量采集 BZOJ - 2005
题目传送门思路:这个题目可以用容斥来做 我们令f[x]为gcd(i, j) = x的个数 令g[x]为i, j因子为x的个数(n / x) * (m / x) 我们再把其中最大公约数不是x的减掉就是要求的答案了#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream原创 2017-10-16 16:26:54 · 464 阅读 · 0 评论
分享