Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in...
分类:
其他好文 时间:
2015-03-30 13:09:17
阅读次数:
161
//比赛时的代码感觉写得真心难看......Orz,还有一堆低级错误贴出来晒晒吧Problem A CodeForces 329A Purification2A 1 #include "bits/stdc++.h" 2 using namespace std; 3 char mat[110][1.....
分类:
其他好文 时间:
2015-03-29 20:45:06
阅读次数:
147
有些程序要处理二进制问题,每个位只包含0和1;标准库里面有个bitset类简化了 处理,使用方便
输入一个整数n
输出n的二进制,保证多少位,高位不够的话补0
#include
#include
#include
#include
using namespace std;
int main()
{
int n;
while(cin>>n)
{
bits...
分类:
其他好文 时间:
2015-03-29 12:19:02
阅读次数:
97
STL 源码剖析
最近打算好好看看STL源码实现...
各种定义找不到头都大了.
首先你需要一个帮手,ctags不行我们就用global(什么东西自己搞定,这么不介绍了).
在STL库的路径下 bits/stringfwd.h你能找到一下定义
你会发现我们常用的标准库类string实质上是basic_string
class string的定义有20...
分类:
其他好文 时间:
2015-03-29 12:15:36
阅读次数:
265
//还是too young,因为没初始化len_name, len_str wa了一发 1 #include "bits\stdc++.h" 2 using namespace std; 3 char name[1010], str[1000010]; 4 5 int main() 6 { 7 .....
分类:
其他好文 时间:
2015-03-28 21:46:55
阅读次数:
224
1 #include "bits/stdc++.h" 2 using namespace std; 3 char mat[110][110]; 4 int m, n; 5 6 int main() 7 { 8 scanf("%d%d", &m, &n); 9 int i, j;1...
分类:
其他好文 时间:
2015-03-28 20:15:34
阅读次数:
165
题目分析:常规解法,实在不知道如何优化了。 1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) 4 { 5 uint32_t m = 0; 6 for (uint32_t i...
分类:
其他好文 时间:
2015-03-28 11:20:17
阅读次数:
101
优先队列
#include bits/stdc++.h>using namespace std;struct cmp{ bool operator() (const int a, const int b) const{ return a%10 > b%10;///定义个位数小的优先级大 }};int main(){ priority_queueint, vecto...
分类:
其他好文 时间:
2015-03-28 08:59:02
阅读次数:
128
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-03-28 01:04:10
阅读次数:
151
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in...
分类:
其他好文 时间:
2015-03-27 23:46:17
阅读次数:
206