BZOJ - 2440 容斥定理】的更多相关文章

组合枚举n/i/i,贡献为miu倍 /*H E A D*/ int mu[maxn],prime[maxn],cnt; bool isprime[maxn]; void sai(int n){ mu[0]=0;mu[1]=1; rep(i,2,n) isprime[i]=1; rep(i,2,n){ if(isprime[i]){ prime[++cnt]=i; mu[i]=-1; } rep(j,1,cnt){ if(i*prime[j]>n) break; isprime[i*prime[j…
2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MB Submit: 7732  Solved: 3750 [Submit][Status][Discuss] Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 100%的数据满足:1≤n≤50000,1≤a≤b≤50000,1≤c≤d≤50000…
How many integers can you find Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3315    Accepted Submission(s): 937 Problem Description   Now you get a number N, and a M-integers set, you shoul…
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/problem/B Description Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of ex…
题目连接:hdu_5213_Lucky 题意:给你n个数,一个K,m个询问,每个询问有l1,r1,l2,r2两个区间,让你选取两个数x,y,x,y的位置为xi,yi,满足l1<=xi<=r1,l2<=y2<=r2,使得x+y=K: 题解:首先,这题没有修改操作,即可以离线,离线区间问题就要想到莫队算法,然后看状态怎么搞,因为要求的答案满足区间的可加性,我们令f(l,r)表示 l到r这个区间满足条件的ans,令F(l1,r1,l2,r2)为在这两个区间内选取的数满足条件的ans,则根…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3556 How Many Sets I Time Limit: 2 Seconds      Memory Limit: 65536 KB Give a set S, |S| = n, then how many ordered set group (S1, S2, ..., Sk) satisfies S1 ∩ S2 ∩ ... ∩ Sk = ∅. (Si is…
题意:给定区间和n,求区间中与n互素的数的个数, . 思路:利用容斥定理求得先求得区间与n互素的数的个数,设表示区间中与n互素的数的个数, 那么区间中与n互素的数的个数等于.详细分析见求指定区间内与n互素的数的个数 容斥原理 AC代码 #include <cstdio> #include <cmath> #include <cctype> #include <bitset> #include <algorithm> #include <cs…
题目 一个有 \(N\) 个 元素的集合有 \(2^N\) 个不同子集(包含空集), 现在要在这 \(2^N\) 个集合中取出若干集合(至少一个), 使得它们的交集的元素个数为 \(K\) ,求取法的方案数,答案模 \(1000000007\) . \((1 \le N \le 10^6, 0 \le K \le N)\) 题解 又是一道 裸的 广义容斥定理 还没这道题难qwq 广义容斥定理 (二项式反演) : \[\displaystyle b_k = \sum_{i=k}^n \binom…
GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4141    Accepted Submission(s): 1441 Problem 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)…
Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 935    Accepted Submission(s): 339 Problem Description Given a number N, you are asked to count the number of integers between A and B in…