摘要: 51nod1079 阅读全文
posted @ 2016-05-28 15:44 PosProteus 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 1 int lowbit(int x) 2 { 3 return x & (-x); 4 } 5 6 int sum(int x) 7 { 8 int ret = 0; 9 while(x > 0) 10 { 11 ret += tmp[x]; x -= lowbit(x); 12 } 13 return ret... 阅读全文
posted @ 2016-05-28 14:38 PosProteus 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 转载自http://www.xuzefeng.com/post/85.html 在性能方面,在虚拟机上运行系统总是弱于在本机上运行,但虚拟机有其便利性。有时候,明明电脑硬件配置是足 够的,但在虚拟机上跑Ubuntu的时候却有点卡。例如,笔者观察到的现象是Ubuntu的界面很卡顿。出现这种现象很有可能 阅读全文
posted @ 2016-05-01 10:58 PosProteus 阅读(452) 评论(0) 推荐(0) 编辑
摘要: 斯特林公式n!=sqrt(2*PI*n)*(n/e)^n 阅读全文
posted @ 2016-04-03 16:41 PosProteus 阅读(411) 评论(0) 推荐(0) 编辑
摘要: 快速计算a^b(x^n),输入在int范围内 注意:在计算矩阵快速幂时采用递归写法容易爆栈 递归写法 循环写法 阅读全文
posted @ 2016-03-12 15:58 PosProteus 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 参考资料: http://www.cnblogs.com/vongang/archive/2012/04/01/2429015.html http://wenku.baidu.com/view/bac23be1c8d376eeafaa3111.html?from=search### 阅读全文
posted @ 2016-03-12 15:30 PosProteus 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 对于非递减序列lower_bound()返回一个 iterator 它指向在[first,last)标记的有序序列中可以插入value,而不会破坏容器顺序的第一个位置,而这个位置标记了一个大于等于value 的值。upper_bound()返回一个 iterator 它指向在[first,last)... 阅读全文
posted @ 2015-11-04 23:10 PosProteus 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1 int binSearch(const int arr[],int low,int high,int key)2 {3 if(low>high)4 return -1;5 int mid=low+(high-low)/2;6 if(arr[mid] == key... 阅读全文
posted @ 2015-09-08 17:30 PosProteus 阅读(199) 评论(0) 推荐(0) 编辑
摘要: hdu 1856 More is better简单的并查集,用到了路径压缩题意:找出节点数最多的连通分支,并输出该节点数。思路:统计每个连通分支的节点数(利用并查集构建图时进行路径压缩,用一个与根节点下标对应的sum数组记录节点数),比较后得出最大值。 1 #include 2 #include 3... 阅读全文
posted @ 2015-08-26 20:00 PosProteus 阅读(162) 评论(0) 推荐(0) 编辑
摘要: hdu 1272 小希的迷宫题意:判断图是否连通且无环;思路:输入边的两点,若两点的父节点相同,则存在环;只有一个根节点则图连通;当输入"0 0"时输出"Yes" 1 #include 2 #include 3 4 int set[100000 + 50]; 5 bool visit[100000... 阅读全文
posted @ 2015-08-24 14:24 PosProteus 阅读(96) 评论(0) 推荐(0) 编辑