相信积累的力量

该文被密码保护。 阅读全文
posted @ 2013-07-24 18:57 ThreeF 阅读(4) 评论(0) 推荐(0) 编辑
摘要: http://en.wikipedia.org/wiki/Fenwick_tree#ifndef TREE_ARR_H#define TREE_ARR_H// index [1, 1024]#define N 1025#define Type intType arr[N];// 核心lowbit函数int lowb(int t) { return t & (-t); }// 一个位置数值改变,由lowbit向后迭代void add(int i, Type v){ for (; i 0; s += arr[i], i -= lowb(i)); return s;}#endif //... 阅读全文
posted @ 2013-07-24 14:05 ThreeF 阅读(189) 评论(0) 推荐(0) 编辑
摘要: /*RMQ离线算法所谓RMQ即(Range Minimum/Maximum Query)区间最小/最大值查找,它可以用来解决多次查找区间内的最大值或最小值。算法需要O(nlogn)的初始化时间以及每次O(1)的查询时间,实在是非常的快啊。例如给定如下23个数,以数组val[23]形式给出(我随机生成的)41 67 34 0 69 24 78 58 62 64 5 45 81 27 61 91 95 42 27 36 91 4 2然后给了一大堆查询,比如查询第2个数到第5个数中的最大值。第7个数到第20个数中的最大值。核心思想是这样的,我们用一个二维数组rmq[i][j]表示从第i个数开始,长度 阅读全文
posted @ 2013-07-24 13:16 ThreeF 阅读(490) 评论(0) 推荐(0) 编辑
摘要: /***************************************************/// 测素数,根号阶bool is_prime(int u){ if(u == 0 || u == 1) return false; if(u == 2) return true; if(u%2 == 0) return false; for(int i=3; i 4, 6, 8, ... //3->9, 12, 15...// 5->25, 30, ... if(mark[i]) { fo... 阅读全文
posted @ 2013-07-24 13:14 ThreeF 阅读(216) 评论(0) 推荐(0) 编辑
摘要: #ifndef GCD_H#define GCD_H#include #include #include /***************************************************/// 最大公约数_int GCD(int x, int y){ int t; while(y > 0) { t = x % y; x = y; y = t; } return x;}/***************************************************/// 快速gc... 阅读全文
posted @ 2013-07-24 13:08 ThreeF 阅读(3391) 评论(0) 推荐(0) 编辑
摘要: http://readanybooks.net/thrillers/TheDaVinciCode/Synopsis:While in Paris on business, Harvard symbologist Robert Langdon receives an urgent late-night phone call: the elderly curator of the Louvre has been murdered inside the museum. Near the body, police have found a baffling cipher. While working 阅读全文
posted @ 2013-07-24 10:49 ThreeF 阅读(284) 评论(0) 推荐(0) 编辑

相信积累的力量