
algorithm
文章平均质量分 80
liutengfeigo
厚德载物,自强不息,独立精神,自由思想.
展开
-
A*,八数码
主要搜索过程: 创建两个表,OPEN表保存所有已生成而未考察的节点,CLOSED表中记录已访问过的节点。 遍历当前节点的各个节点,将n节点放入CLOSE中,取n节点的子节点X,->算X的估价值-> While(OPEN!=NULL) { 从OPEN表中取估价值f最小原创 2011-07-25 13:28:28 · 1811 阅读 · 1 评论 -
15-Puzzle Problem
转载自点击打开链接// You can fool some of the people all of the time, and all of the people// some of the time, but you can not fool all of the peop转载 2011-07-26 22:36:10 · 2435 阅读 · 0 评论 -
最小圆覆盖,随机增量法.
#include#include#include/* algorithm: A、令Ci表示为前i个点的最小覆盖圆。当加入新点pi时如果pi不在Ci-1里那么pi必定在Ci的边界上。 B、再从新考虑这样一个问题,Ci为前i个点最小覆盖圆且p在Ci的的边界上!同原创 2011-08-04 21:48:05 · 5597 阅读 · 0 评论 -
多重背包,二进制优化,单调队列优化
采药【问题描述】辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个山洞里有一些不同的草药,采每一株都需要一些时间,每一株也有它自身的原创 2011-08-19 20:11:37 · 2293 阅读 · 1 评论 -
AC自动机
看了这些博客后,自己写的代码.http://www.cppblog.com/mythit/archive/2009/04/21/80633.htmlhttp://apps.hi.baidu.com/share/detail/16394130http://apps.hi.baidu.com/share/detail/16394130http://www.notonlysuccess.原创 2012-02-28 20:48:31 · 921 阅读 · 0 评论 -
Hamming weight
http://en.wikipedia.org/wiki/Hamming_weight#include const int m1 = 0x55555555;const int m2 = 0x33333333;const int m4 = 0x0f0f0f0f;const int m8 = 0x00ff00ff;const int m16 = 0x0000ffff;int Pop原创 2012-04-27 15:15:15 · 1162 阅读 · 0 评论 -
天下大事,必做于细!
#include /* 减少while里的那次判断.这样的代码更加好. */ int binarySearch(int a[], const int & len, const int & value){ int low = -1; int high = len; while (high - low > 1) { int mid原创 2012-04-25 21:13:02 · 999 阅读 · 0 评论 -
好吧,我也可以裸写快排了.
#include int partition(int a[], int p, int r){ int x = a[r]; int i = p-1; int tmp = 0; for (int j = p; j < r; ++j) { if (a[j] <= x) { ++i; tmp = a[j]原创 2013-06-11 12:05:39 · 1559 阅读 · 0 评论