解题思路:
(1)将需要翻转的数n跟1进行“&”运算,取得最低位上的数,
(2)左移到对应位置上,实现翻转。
(3)将翻转的结果加入到result中
(4)将n>>1右移一位,继续遍历...
分类:
其他好文 时间:
2015-06-18 09:43:49
阅读次数:
72
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return...
分类:
其他好文 时间:
2015-06-16 20:48:13
阅读次数:
101
275
Description
给定A,B,X≤200A,B,X\le 200,让你求出有多少个YY满足X?i+Y?jX*i+Y*j可以表示所有的A?p+B?qA*p+B*q
Solution
首先如果XX是A和BA和B的约数的话,显然Y是无穷多个,否则我们可以暴力枚举YY,判断X和YX和Y的线性组合是否可以表示A和BA和B,如果可以的话答案+1。
Code#include <bits/s...
分类:
其他好文 时间:
2015-06-15 22:10:52
阅读次数:
127
算数类型(Arithmetic Types)
c++算数类型
Type
Meaning
Minimum Size
bool
boolean
NA
char
character
8 bits
wchar_t
wide character
16 bits
char16_t
Unicode character
16 bi...
分类:
编程语言 时间:
2015-06-15 18:44:43
阅读次数:
167
题意:
求1~n的二进制中连续出现的两个1有多少个
思路:
首先枚举两个1的位置,如果此时枚举的位置与元素一样,则还要多加
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#inclu...
分类:
其他好文 时间:
2015-06-15 16:26:30
阅读次数:
101
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 000000000000...
分类:
其他好文 时间:
2015-06-15 13:10:05
阅读次数:
99
root@k101:/ # cat /sys/class/lcd/debug
Usage:
echo basic > debug ; write lcd basic config
echo type > debug ; write lcd type & bits
echo ...
分类:
其他好文 时间:
2015-06-11 19:26:18
阅读次数:
193
A. Two Substrings
题意:问一个字符串中是否同时存在AB和BA,其中AB和BA不能共用同一个B或A。
题解:扫一遍即可。可以考虑如下策略:先找AB,然后从B后的位置继续找BA;再另按BA-AB的顺序找一遍即可。复杂度O(n)O(n)。窝的代码则直接暴力出所有的AB和BA位置,只要出现不重叠的两个就OKOK~数据不大,随便搞。
参考代码:
#include <bits/stdc++.h...
分类:
其他好文 时间:
2015-06-11 09:34:23
阅读次数:
263
源:JAVA判断32位还是64位,调用不同的DLL通过获取sun.arch.data.model可判断是32还是64的JAVA将32或者64位的DLL放不同的目录,实现自适应调用DLL Properties props = System.getProperties(); String bits=.....
分类:
编程语言 时间:
2015-06-08 13:19:56
阅读次数:
155
template class bitset; BitsetA bitset stores bits (elements with only two possible values: 0 or 1, true or false, ...).[bitset存储位(元素只能为两种可能的数值,即0或1,tr...
分类:
其他好文 时间:
2015-06-07 17:16:44
阅读次数:
133