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 |
此题若用A*,h函数怎么设计?请过的人回答下我的g函数用的是已走的步数,然后加了下面注释中的条件题目就过不了(不加能过但速度不行) if( board[next.x][next.y]==0 /*|| (board[next.x][next.y]==1 && cur.g+1<next.g)*/ ) 我的h函数 inline int h(Node a) { return (int)floor(sqrt((double)(abs(a.x-end.x)*abs(a.x-end.x)+abs(a.y-end.y)*abs(a.y-end.y)))/sqrt(5.0)+0.0001); //return (int)ceil(double(abs(a.x-end.x)+abs(a.y-end.y))/3.0-0.000001); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator