HDU 6186 CS Course (连续位运算)】的更多相关文章

CS Course Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 430    Accepted Submission(s): 222 Problem Description Little A has come to college and majored in Computer and Science. Today he has le…
[前后缀枚举] #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include<cstring> #include<set> #include<queue> #include<algorithm> #include<vector> #include<map…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5014 解题报告:西安网赛的题,当时想到一半,只想到从大的开始匹配,做异或运算得到对应的b[i],但是少了一个操作,ans[i] = temp,却没有想到ans[temp] = i;所以就一直卡在这里了,因为我不确定这样是不是一一对应的,好吧,也没有想到这里,就差这么点了. #include<cstdio> #include<cstring> #include<iostream&g…
http://acm.hdu.edu.cn/showproblem.php?pid=5491 题目大意:给定一个数D,它的二进制数中1的个数为L,求比D大的数的最小值x且x的二进制数中1的个数num满足s1 <= num <= s2   分析:将D+1变成n,求其二进制数中1的个数L   (1)如果L在(s1, s2)范围内,直接输出   (2)如果num<s1,从右到左找0的最小位i,将该位的0改成1(即:1的个数少了,增加一个1),n的值则增加2^i(即:n += 2^i)    (…
http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给出n个数,共有n次询问,每次询问给出一个数p,求除去第p个数后的n-1个数的&.|.^值. 思路:分别计算出&.|.^的前缀和后缀,将前缀和后缀相计算即可. #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ; int n, q; int a[maxn…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给了n个数,然后有q个查询,每个查询要求我们删掉一个数,问删掉这个数后整个序列的与值,或值,异或值的和. 解法: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5+5; int n, m, a[maxn], sum1[maxn][2], sum2[maxn][2], sum3[maxn][2]; int…
题意: 从给出的颜料中选出天数个,第一天选一个,第二天选二个... 例如:第二天从4个中选出两个,把这两个进行异或运算(xor)计入结果 对于每一天输出所有异或的和 $\sum_{i=1}^nC_{n}^{i}$ 思路: 0⊕0=0,1⊕0=1,0⊕1=1,1⊕1=0(同为0,异为1) 例如样例 4 1 2 10 1 这4个数的二进制表示分别为: 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 第一天: 分别选出 1, 2, 10 ,1 = 14 第二天: 从4个中选出2个进行异…
保存前缀后缀. 保存一下前缀和后缀,去掉第$i$个位置,就是$L[i-1]$和$R[i+1]$进行运算. #include<bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; int Land[maxn], Rand[maxn]; int Lor[maxn], Ror[maxn]; int Xor; int a[maxn]; int n, p; int main() { while(~scanf("%d%…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3006 题目大意:给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.由给出的集合可以组成多少个不同的集合. 输入描述:第一行为n,m,接下来n行,每行包含k+1个数字,第一个为k,表示该集合的元素个数,接下来k行表示集合元素. Sample Input 4 4 1 1 1 2 1 3 1 4 2 4 3 1 2 3 4 1 2 3 4   Sample Output 15 2…
题意: 给出n个地雷所在位置,正好能够组成正方形的地雷就可以拿走..为了简化题目,只考虑平行于横轴的正方形.. 问最多可以拿走多少个正方形.. 思路: 先找出可以组成正方形的地雷组合cnt个.. 然后st = 1<<cnt.. 用位运算来考虑取哪一个组合可以拿走最多的地雷且满足题目条件.. Tips: 题目比较烦恼的地方是解决: ①. 所选集合里面的地雷会不会重复拿.. ②. 所选集合里面在同一个地方取走的地雷会不会比该地方题目给出的地雷数多.. 同一个地点可能有多个地雷,如果用去重就不好算多…