zoj 3870】的更多相关文章

题目传送门 /* 题意:找出符合 A^B > max (A, B) 的组数: 位运算:异或的性质,1^1=0, 1^0=1, 0^1=1, 0^0=0:与的性质:1^1=1, 1^0=0, 0^1=0, 0^0=0: 假设A < B,一定要满足B的最高位对应A的值是0,这样才可能>B(即0^1=1): 然后比赛时假设A的极限是类似0111111的情况,最后假设有误: 题解是先把每个数最高位(1)的位置统计个数,1<<4 的意思是 000010000: 只要与为0,表示最高位p…
链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3870 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88230#problem/I   (密码:0817) 题目大意:从n个数中取2个数,问有多少种方法取的两个数的异或大于两个数的最大数思路:如果x的最高位i位是1,y的位是0,且y比x大,i不是y的最高位,异或后这一位变成1,且yi位以前的1也可以保存…
题意 n个数,找出有几对a.b 符合 a ^ b > max(a,b) .^表示异或号 分析 对于数a,如果它的二进制是: 1 0 1  0 0 1,那么和它 ^ 后 能比他大的数就是: 0 1 X X X X 0 0 0 1 X X 0 0 0 0 1 X 所以对应的b 在a的最高位1到后面第一次出现0之前,都为0,然后在a为0的位置里至少一个为1. 于是就是最高位1的位置有几个数储存下来就可以计算了. 代码 #include<cstdio> #include<cstring&g…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5518 题意:n个数,从中选出两个数,问这两个数的异或值大于两个数较大的数的组合有多少种 题目分类:异或 代码: #include<bits/stdc++.h> using namespace std; ; ]; // bit[i]表示有多少个数的最高位的1在第i位上 void solve(int x) { ; ) { <<l)) { bit[l]++;…
Team Formation Time Limit: 3 Seconds      Memory Limit: 131072 KB For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level of each stud…
                                                B - Team Formation Description For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level…
For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level of each student. He has found that if two students with skill level A and B fo…
题意:给定N个数,求这N个数中满足A ⊕ B > max{A, B})的AB有多少对.(A,B是N中的某两个数) 分析: 1.异或,首先想到转化为二进制. eg:110011(A)和 1(B)--------A中从右数第三个数是0,若某个数B(eg:110,101,111,……)从左向右数第三个数为1,那么两个异或一定满足A ⊕ B > max{A, B}). 还有哪些数B能让A ⊕ B > max{A, B})呢? 根据上述,同理,从右数第四个为1的数B也符合要求. 很容易想到,将N个…
Team Formation Time Limit: 2 Seconds Memory Limit: 131072 KB For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team from N students of his university. Edward knows the skill level of each student.…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…