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-04-05 23:20:17
阅读次数:
177
拓扑排序
拓扑排序
一:使用DFS实现二:使用入度概念以及队列处理1.使用一般队列2.使用优先队列(这里定义越大的整数拥有越大的优先级)
一:使用DFS实现
#include bits/stdc++.h>using namespace std;#define maxn 10000 + 10int c[maxn],topo[ma...
分类:
编程语言 时间:
2015-04-05 17:33:41
阅读次数:
132
一句话的事,直截了当——#include包含C++的所有头文件参考网站(点击):http://www.tuicool.com/articles/m6neUj#include这个头文件包含以下等等C++中包含的所有头文件:#include #include #include #includ...
分类:
编程语言 时间:
2015-04-03 20:55:20
阅读次数:
135
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-04-03 19:11:16
阅读次数:
86
窝觉得Floyd好简单,dikstra跟Floyd一样都是n3,还是觉得Floyd写起来简单hdu2544代码:#include "bits/stdc++.h"#define inf 0x3f3f3f3fint dis[110][110];int main(){ int i,j,k,t; int n...
分类:
其他好文 时间:
2015-04-03 13:09:40
阅读次数:
108
打开文件的系统调用是open(),在内核中通过sys_open()实现,假设filename是"/usr/local/hello.c",且假设这个文件已经存在,代码如下:asmlinkage long sys_open(const char * filename, int flags, int mode)
{
char * tmp;
int fd, error;
#if BITS_PER_L...
分类:
系统相关 时间:
2015-04-03 11:15:40
阅读次数:
173
链接: https://leetcode.com/problems/reverse-bits/
此题的关键是预先将1
class Solution {
public:
Solution(){
unsigned int i = 0;
unsigned int j = 1;
for(; i < 32; i++)
a[i] = (j<<(31-i));
}
...
分类:
其他好文 时间:
2015-04-01 20:01:40
阅读次数:
126
链接:https://leetcode.com/problems/number-of-1-bits/
此题关键是如何判断一个数字的第i为是否为0 即: x& (1
class Solution {
public:
int hammingWeight(uint32_t n) {
int count = 0;
for(int i = 0; i < 32; ...
分类:
其他好文 时间:
2015-04-01 20:01:26
阅读次数:
122
二进制转换和字符串逆序。要考虑int的范围,测试数据是有溢出的。Math.pow是有精度损失的,最好写成整数的。public class ReverseBits { public static int reverseBits(int n) { StringBuilder...
分类:
其他好文 时间:
2015-04-01 01:40:34
阅读次数:
122
题目描述:
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 representa...
分类:
其他好文 时间:
2015-03-30 18:42:17
阅读次数:
128