主页面:http://blog.csdn.net/dolfamingo/article/details/77825569
关于A*算法:g(n)表示从起点到任意节点n的路径花费,h(n)表示从节点n到目标节点路径花费的估计值(启发值),f(n) = g(n)+h(n)。
A*算法必须满足的条件(能不能满足由所选的h(n)估计方式决定):每次扩展的节点的 f 值 >= 父节点的 f 值小。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <set>
#define ms(a,b) memset((a),(b),sizeof((a)))
using namespace std;
typedef long long LL;
const int INF = 2e9;
const LL LNF = 9e18;
const int MOD = 1e9+7;
const int MAXN = 1e6+10;
#define AIM 1 //123456789的哈希值为1
struct node
{
int statu