D. Little Girl and Maximum XOR
A little girl loves problems on bitwise operations very much. Here's one of them.
You are given two integers
l and r. Let's consider the values of
for all pa...
分类:
其他好文 时间:
2015-04-10 09:40:40
阅读次数:
147
这两个题,都是用bit operation解决的,但是第二个稍微tricky一点。先说第一个,我们利用XOR, 如果一个数字出现两次,那么在每一位上,两两抵消。唯独那个只出现一次的,没有另一半和它抵消了。。所以就剩下了。 1 public int singleNumber(int[] A) ...
分类:
其他好文 时间:
2015-04-10 08:15:03
阅读次数:
108
可持久化trie树 可持久化trie树现在想来是比较好理解的了,但却看了一个下午... 相当于对于每个状态建立一条链(或者说一棵trie),求解的时候只要让两个点按照相同的步子走然后看sum的大小关系即可。 tr[y].son[p xor 1]:=tr[x].son[p xor 1]; ...
分类:
其他好文 时间:
2015-04-09 21:29:58
阅读次数:
150
Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 to n, inclusive.For permutation p?=?p0,?p1,?…,?pn, Polo has defined its beauty — number .Expression mean...
分类:
其他好文 时间:
2015-04-08 18:08:05
阅读次数:
144
题目传送门 1 /* 2 线段树的单点更新:有一个交叉更新,若rank=1,or;rank=0,xor 3 详细解释:http://www.xuebuyuan.com/1154895.html 4 */ 5 #include 6 #include 7 #include 8 #i...
分类:
其他好文 时间:
2015-04-08 14:44:04
阅读次数:
111
异或满足交换律,结合律任何数X^X=0,X^0=X自反性 A XOR B XOR B = A xor 0 = A设有A,B两个变量,存储的值分别为a,b,则以下三行表达式将互换他们的值 表达式 (值) :A=A XOR B (a XOR b)B=B XOR A (b XOR a XOR b = a)...
分类:
其他好文 时间:
2015-04-08 10:51:53
阅读次数:
138
从高到低运算符类型()括号++--自增/自减!逻辑*/%算术+-.算术和字符串<<>>按位<<=>=>比较==!=====!==比较&按位(和引用)^按位|按位&&逻辑||逻辑?:三元=+=*=.=%=&=!=^=<<=>>=赋值and逻辑xor逻辑or逻辑
分类:
Web程序 时间:
2015-04-07 20:01:08
阅读次数:
106
Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1,?x2,?…,?xk (k?>?1) is such maximum element xj, that the following in...
分类:
其他好文 时间:
2015-04-03 15:21:56
阅读次数:
154
Description给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点间第K小的点权。其中lastans是上一个询问的答案,初始为0,即第一个询问的u是明文。Input第一行两个整数N,M。第二行有N个整数,其中第i个整数表示点i...
分类:
其他好文 时间:
2015-04-03 15:08:00
阅读次数:
114
一、 位运算符 在一般的应用中,我们基本上用不到位运算符。虽然,它比较基于底层,性能和速度会非常好,而就是因为比较底层,使用的难度也很大,底层运算是转换成二进制进行运算的。 位运算符有七种,分别是:位非 NOT(~)、位与 AND(&)、位或 OR(|)、位异或 XOR(^)、左移(>)、无符号.....
分类:
编程语言 时间:
2015-04-01 19:38:32
阅读次数:
218