Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
是这样的 结论(空格为n*n*n) 对于一个n数码 形成一个序列 {1,2,3,4...n*n*n} 若该序列的逆序对为a; 定义dist为:空格的位置与终止转状态的哈密顿距离b=|x1-x2|+|y1-y2|+|z1-z2|; 若cnt=a+b为偶数则有解否则则无解 if(cnt % 2 == 0) puts("Puzzle can be solved."); else puts("Puzzle is unsolvable."); Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator