#include#include#include#includeusing namespace std;const int maxn=120;long long X,K;long long basex[maxn];long long basek[maxn];int totx,totk;int ma....
分类:
其他好文 时间:
2015-12-27 19:02:27
阅读次数:
123
Problem DescriptionYou are given two positive integers X and K. Return the K-th smallest positive integer Y, for which the following equation holds: X...
分类:
其他好文 时间:
2015-12-26 18:28:49
阅读次数:
165
题意:已知x,k求第k个使得x+y==x|y的正整数yx+y==x|y即x为1的位y为0可知y有几位可以为1详见代码#include#include#include#include#include#includeusing namespace std;const int N=50005;int n,...
分类:
其他好文 时间:
2015-12-26 18:27:16
阅读次数:
189
Given a range [m, n] where 0 maxRange) continue; 9 int mi = (m>>i) & 1;10 int ni = (n>>i) & 1;11 if (mi == 1 && n...
分类:
其他好文 时间:
2015-12-15 06:24:22
阅读次数:
156
由于位运算直接对内存数据进行操作,不需要转成十进制,因此处理速度非常快。按位与(Bitwise AND),运算符号为&a&b 的操作的结果:a、b中对应位同时为1,则对应结果位也为1、例如:10010001101000101011001111000& 111111100000000 --------...
分类:
编程语言 时间:
2015-12-12 07:04:31
阅读次数:
290
LeetCode -- Bitwise AND of Numbers Range...
分类:
其他好文 时间:
2015-11-21 10:36:42
阅读次数:
137
转自: http://www.cnblogs.com/elementstorm/archive/2013/04/10/3012679.htmlanon :true //匿名函数声明中function关键字与()之间的空白可以被省略bitwise : true //允许按位运算browser : .....
分类:
Web程序 时间:
2015-11-08 15:06:19
阅读次数:
297
上篇的链接为:http://www.cnblogs.com/jiu0821/p/4677184.html这次是偶然看到一个题目,很好玩,便记在这里吧!Bitwise AND of Numbers Range给出一个范围,[m, n](0 >=1; 7 n>>=1; 8 ...
分类:
其他好文 时间:
2015-11-03 02:00:41
阅读次数:
264
原题链接在这里:https://leetcode.com/problems/bitwise-and-of-numbers-range/其实就是找n最大的bit上对应的m的bit是否为1, 若不是1, 就返回0; 若是1, 就返回那个bit上为1后面为0的数字,如100=4.AC Java: 1 pu...
分类:
其他好文 时间:
2015-10-29 12:41:40
阅读次数:
122
Given a range [m, n] where 0 m) n &= n - 1; return n; }
分类:
其他好文 时间:
2015-09-13 19:52:42
阅读次数:
164