#include#include#include#include#include#include#include#include#includeusing namespace std;
typedef int state[9];
const int maxn=1000000;
state st[maxn],goal; //相當於st[maxn][9]儲存走的每一步下的8個數字的;goal[9]儲存目標;
int dist[maxn]; //距離,即走了幾步;
const int dx=;
const int dy=;
bool inside(int x,int y)
int bfs()
bool try_to_insert(int n)
2)hash表
const int hashsize=1000003;
int head[maxn],next[maxn];
void init_table()
int hash(int n) //將9個數對映為符合hashsize的數
bool try_to_insert(int s)
next[s]=head[h]; //當前s這一步指向下乙個同樣的hash數的s值即head[h];
head[h]=s; //當前hash數h指向s這一步,即更新到同樣的hash數的最前面的s位置;
return true;
}
八數碼問題,bfs,hash,康托
關於康托的講解 康托展開 康托展開的公式 把乙個整數x展開成如下形式 x a n n 1 a n 1 n 2 a i i 1 a 2 1 a 1 0 其中,a為整數,並且0 a i 康托展開的應用例項 表示1,2,3,n的排列如 按從小到大排列一共6個。123 132 213 231 312 321...
八面玲瓏的linux語言
學習linux需要用到各種各樣的語言,我認為其中有五種語言是必不可少的,下面就是我總結的一些我認為的linux必會語言 1.英語 對於linux,很多人甚至連 linux怎麼讀 都不清楚,所以即使你不學linux,我也強烈建議你學好英文,因為實質上計算機語言就是英文和字元,所謂的多國語言只是外部包裝...
職場江湖 告訴你如何八面玲瓏
雖說大多數的人都身處於職場之中,但他們的職場eq有多高呢?有多少人是在職場中 混 得八面玲瓏,多少人的工作成績是被老闆知道的?又有多少人會主動把自己的成績告訴老闆,以便讓自己的努力不付諸東流呢?把成績告訴老闆 謙虛是好的,可過分的謙虛卻會讓人覺得是一種驕傲,這種謙虛會使你的工作激情永遠沉寂 分析 乙...