码迷,mamicode.com
首页 >  
搜索关键字:std    ( 41627个结果
求二进制数中1的个数
问题:对于一个字节(8bit)的无符号整形变量,求二进制表示中“1”的个数,要求算法的执行效率尽可能高。 1 #include 2 using namespace std; 3 //最简单的思路,除2有余数 4 int fun1(unsigned int a) 5 { 6 int coun...
分类:其他好文   时间:2014-05-01 19:47:34    阅读次数:355
sdut 2847 Monitor (思维题)
题目题意:给定a, b, x, y; 求使c, d; 使c:d = x :y; 且c 2 #include 3 #include 4 #include 5 using namespace std; 6 7 long long gcd(long long a, long long b) 8 {...
分类:其他好文   时间:2014-05-01 19:30:04    阅读次数:372
多线程-5
#include #include //using namespace std; DWORD WINAPI Fun1Proc( LPVOID lpParameter // thread data ); DWORD WINAPI Fun2Proc( LPVOID lpParameter // thread data ); int index=0; int tickets=100;...
分类:编程语言   时间:2014-05-01 18:25:42    阅读次数:323
A*算法的寻路中的应用——无阻挡
按照之前转载的文章,自己先实现了下,表示还是很多坑: #include "stdio.h" #include #include #include #include using namespace std; int neigor[][2] ={ {-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0} }...
分类:其他好文   时间:2014-05-01 18:03:27    阅读次数:320
POJ 3882 Stammering Aliens 后缀数组height应用
题目来源:POJ 3882 Stammering Aliens 题意:给你m一个一个字符串 求至少出现m次的最长字符串 可以在字符串中重叠出现 思路:二分长度l 然后从height数组中找长度大于等于l的前缀 #include #include #include using namespace std; const int maxn = 40010; char s[maxn]; in...
分类:其他好文   时间:2014-05-01 17:36:34    阅读次数:334
POJ - 2926 Requirements
题意:多维的曼哈顿最远距离 思路:做了1,2,3维的,其实就是枚举所有绝对值的可能的表达式 #include #include #include #include using namespace std; const int MAXN = 100005; const int M = 5; const double inf = 1e200; struct node{ double x...
分类:其他好文   时间:2014-05-01 17:31:01    阅读次数:283
hdu 1160 FatMouse's Speed
题目:寻找最长上升自序列。 代码: #include #include #include #include using namespace std; struct node { int w,s; //重量,速度 int num; //编号 int t; //用来记录当前编号...
分类:其他好文   时间:2014-05-01 17:17:32    阅读次数:285
c++调用基类的构造函数(模板类)
代码如下 #include #include #include using namespace std; template class Base { public: Base(T name); virtual void toString(); protected: T id; }; template Base::Base(T n) { printf("B...
分类:编程语言   时间:2014-04-30 22:27:39    阅读次数:450
大数减法(改天弄PPT上去,现在太晚了,要睡觉了)
大数乘法的步骤(先戳我看看大数加法的思想): 首先是输入2个数据,并且逆序,还要去掉前导0。比较大小: 相等的话,结果为0。前者大于后者,则直接进行减法运算。前者小于后者,则用后者减去前者,最后在结果前面添上负号。 从最高位开始输出结果。 #include #include #define MAX 1000 using namespace std; void InputNu...
分类:其他好文   时间:2014-04-30 22:17:40    阅读次数:231
大整数的加减乘除
多项式的加减乘除可以利用多项式的加减乘除进行运算,所以以下程序采用了多项式的加减乘除。多项式运算已经在《算法导论》第30章有简要的介绍,具体的请参考数学书。 大整数加法:(利用书上公式轻松得出) //多项式加法-大数加法 #include #include using namespace std; #define m1 4 #define m2 5 //a[0]=x^0 a[1]=x^1....
分类:其他好文   时间:2014-04-29 13:46:21    阅读次数:326
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!