HDU 6397 组合数学+容斥 母函数】的更多相关文章

Character Encoding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1473    Accepted Submission(s): 546 Problem Description In computer science, a character is a letter, a digit, a punctuation…
Frogs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1315    Accepted Submission(s): 443 Problem Description There are m stones lying on a circle, and n frogs are jumping over them.The stones a…
给出n个数,给出m个询问,询问 区间[l,r] [u,v],在两个区间内分别取一个数,两个的和为k的对数数量. $k<=2*N$,$n <= 30000$ 发现可以容斥简化一个询问.一个询问的答案为 $[l,v]+(r,u)-[l,u)-(r,v]$,那么我们离线询问,将一个询问分成四个,分块暴力就行了. 然后就是注意细节,不要发生越界,访问错位置之类比较蠢的问题了. /** @Date : 2017-09-24 19:54:55 * @FileName: HDU 5213 分块 容斥.cpp…
求满足$1<=X<=N ,(X,N)>=M$的个数,其中$N, M (2<=N<=1000000000, 1<=M<=N)$. 首先,假定$(x, n)=m$,那么 $(\frac{x}{n},\frac{n}{m})=1$,故$$ans=\sum_{i=m}^{n}\varphi(\frac{n}{i})$$ ん?遅い! $$\sum_{i=m}^{n}\varphi(\frac{n}{i})=\sum\limits_{d|n}{\varphi(\frac{n}…
题意: 析:首先很容易可以看出来使用FFT是能够做的,但是时间上一定会TLE的,可以使用公式化简,最后能够化简到最简单的模式. 其实考虑使用组合数学,如果这个 xi 没有限制,那么就是求 x1 + x2 + x3 +... xm = k,有多少非零解,隔板法很容易得到答案 C(k+m-1, m-1),但是有限制怎么办,使用容斥,考虑有一个变量超过 n-1,两个变量超过 n-1,等等,根据集合论,很容易知道偶加,奇减... 代码如下: #pragma comment(linker, "/STACK…
GCD 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1695 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…
Frogs Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5514 Description There are m stones lying on a circle, and n frogs are jumping over them.The stones are numbered from 0 to m−1 and the frogs are numbered fro…
Lucky7 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5768 Description When ?? was born, seven crows flew in and stopped beside him. In its childhood, ?? had been unfortunately fall into the sea. While it was dying, seven dolphins arched its body an…
http://acm.hdu.edu.cn/showproblem.php?pid=5212 题意:忽略.. 题解:把题目转化为求每个gcd的贡献.(http://www.cnblogs.com/z1141000271/p/7419717.html 和这题类似 反向容斥)这里先用容斥写了,mobious的之后再说吧23333. 然后比较想说的是这个调和级数的复杂度 nlog(n) ac代码: #include <iostream> #include <cstdio> #includ…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5514 题意:有m个石子围成一圈, 有n只青蛙从跳石子, 都从0号石子开始, 每只能越过xi个石子.问所有被至少踩过一次的石子的序号之和. 题解:根据裴蜀定理每个青蛙可以跳到的最小石子编号为 gcd(xi,m) = bi,所有小于 m 的 bi 的倍数都是可以到达的石头.显然所有 bi 都为 m 的因子,标记 m 中所有能到达的因子,进行容斥,比如因子2.3.6都可以到达,计算 2 和 3 的倍数的时…