按位贪心。 前缀异或和没话说。一位为0当且仅当这一位有m个0,且第n个数这一位为0。 如果这一位可以为0,那么所有这一位为1的数以后都不能选。 ...
分类:
其他好文 时间:
2016-09-16 21:18:04
阅读次数:
140
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example:Given a = 1 and b = 2, return 3. 思路:xor相加存无car ...
分类:
其他好文 时间:
2016-09-13 13:06:12
阅读次数:
254
E. XOR and Favorite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Bob has a fav ...
分类:
编程语言 时间:
2016-09-12 14:00:57
阅读次数:
174
Missing Number [Problem] [Solution2] sum: Time~O(n) Space~O(1) //overflow riskmissing = expected_sum - actual_sum = (0+n)(n+1)/2 - sum [Solution1] xor ...
分类:
其他好文 时间:
2016-09-12 06:15:10
阅读次数:
124
GitHub: https://github.com/seventheli/LeetCode-Practice singleNumber Core: A XOR B XOR A XOR C XOR B = C Core: Serializing String Value, then descendi ...
分类:
编程语言 时间:
2016-09-08 23:06:46
阅读次数:
153
XMAX - XOR Maximization Given a set of integers S = { a1, a2, a3, ... a|S| }, we define a function X on S as follows:X( S ) = a1 ^ a2 ^ a3 ^ ... ^ a|S ...
分类:
其他好文 时间:
2016-09-08 18:06:43
阅读次数:
133
原题地址:http://codeforces.com/gym/100307/problem/H 题意: 给定一个序列,求序列的子区间中,满足子区间XOR值等于AND值得子区间个数。 题解: 一直以为NEERC这种有名的比赛应该题解到处都是,太天真了…… 首先考虑区间的AND值。 对于固定起点的区间, ...
分类:
其他好文 时间:
2016-09-04 15:40:15
阅读次数:
121
题目来源: Ural 1318 给出n个互不相等的整数A[0] - A[n-1],选A[i]同A[j]进行异或运算(结果都 > 0无符号),对结果取lg(以10为底)并取整后记为L[i,j],求n个数之间两两运算得到的L[i,j]之和。 例如:1 10 30,1 xor 10 = 11,10 xor ...
分类:
其他好文 时间:
2016-08-18 00:51:43
阅读次数:
253
题目链接:Vasiliy's Multiset 题意:这里有一个set容器,有三种操作,+ num, - num, ? num,分别代表往容器里加上num,或者拿走num,或着从容器里找一个数temp使得temp^num的值最大。输出这个最大值。 思路:对于XOR操作,一般都要拆位考虑,拆完之后用T ...
分类:
其他好文 时间:
2016-08-15 20:34:20
阅读次数:
127