HDU 1372
摘要:bfs 的题目http://acm.hdu.edu.cn/showproblem.php?pid=1372题目简述:一个8*8的棋盘,输入两点,求马从第一点到第二点所需要的最少步数Inpute2e4a1b2b2c3OutputTogetfrome2toe4takes2knightmoves.Togetfroma1tob2takes4knightmoves.Togetfromb2toc3takes2knightmoves.代码:#include<iostream>#include<queue>using namespace std;int map[10][10];int
阅读全文
posted @
2013-05-27 09:01
努力ing
阅读(139)
推荐(0)
hdu 1978
摘要:记忆搜索http://acm.hdu.edu.cn/showproblem.php?pid=1978题目简述:机器人从第一个点出发到达最后一点,有多少种方法,结果%10000;Input166456643223172114627584395766215311372Output3948第一种方法:#include<iostream>using namespace std;int n,m;int map[205][205];int dp[205][205];int min(int a,int b){ return a<b?a:b;}int bfs(int x,int y,int
阅读全文
posted @
2013-05-23 15:46
努力ing
阅读(161)
推荐(0)
hdu 1242
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1242用bfs做,要用优先队列#include<iostream>#include<string>#include<queue>using namespace std;int sx,sy,ex,ey;int n,m;int map[205][205];int dis[4][2]={0,1,1,0,0,-1,-1,0};struct node{ int x,y; int step; friend bool operator<(node a,node b) //优先队列必
阅读全文
posted @
2013-05-19 22:09
努力ing
阅读(223)
推荐(0)
hdu 1253
摘要:广搜的题目http://acm.hdu.edu.cn/showproblem.php?pid=1253用优先队列会超时时间少,空间大#include<iostream>#include<queue>using namespace std;int a,b,c,t;int map[55][55][55];int dir1[2]={1,-1};int dir2[4][2]={{1,0},{0,1},{-1,0},{0,-1}};struct node{ int x,y,z; int time;};bool cmp(int v,int w,int u){ if(v<0||
阅读全文
posted @
2013-05-19 22:02
努力ing
阅读(129)
推荐(0)