搜索
zhang_li_yang
这个作者很懒,什么都没留下…
展开
-
杭电1010-搜索&&迷宫问题
迷宫问题,注意剪枝!!! AC代码: #include #include int n,m,t,flag; int startx,starty,endx,endy,starttime,wallnum; int movex[]={0,-1,0,1},movey[]={-1,0,1,0};// char maze[10][10]; int abs(int a,int b) { int c; c=原创 2013-04-22 17:06:32 · 783 阅读 · 0 评论 -
杭电1241-搜索专题&&迷宫问题
dfs()水题: #include #include int m,n; char maze[105][105]; int dfs(int a,int b) {//深度遍历图结构,遍历完一次,说明图的区块加1 , int i; int x,y; int movex[]={-1,0,1,-1,1,-1,0,1}; int movey[]={1,1,1,0,0,-1,-1,-1}; if(原创 2013-04-23 08:54:58 · 766 阅读 · 0 评论 -
杭电1242-搜索专题&&迷宫问题
本题和前面搜索题目有一点区别,前面的题目都是从起点开始搜索,而本题是从终点开始搜索,因为起点不止一个!!!! 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1242 AC代码: #include #include int m,n,flag,min; int startx,starty,endx,endy; int movex[]={1,0,-1原创 2013-04-24 20:26:11 · 749 阅读 · 0 评论 -
杭电1312-搜索
深度优先搜索: #include #include #include int n,m; int hash[30][30];//记录是否是。 char map[30][30];//迷宫,要初始化 void DFS(int x,int y) { if(x>n||y>m||hash[x][y]||map[x][y]=='#') return;//走过了,则原创 2013-04-26 20:52:23 · 671 阅读 · 0 评论 -
杭电1238—搜索入门题目&&字符串处理
开始感觉这题很简单,直接暴力就行!!!但是显而易见,暴力是解决不了问题的,,特别是这题作为亚洲区预选赛的题目、、、、就更没那么容易过了。题目大意是这样的:给定一些字符串,类似最长公共子串,但是有点不同的是这题要考虑反串的情况,即如果反串满足最长子串,那同样是可以的。。。 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1238原创 2013-04-21 15:15:32 · 736 阅读 · 0 评论 -
杭电1239—搜索
题目大意: a.给定整数m,a,b(4 1 b.需要找到两个数(不妨设为p,q)满足以下条件: p,q均为质数; p*q a/b c.输出所有满足以上条件的p,q中乘积最大的一对p,q 实现代码1(本人的): #include #include int is_prime(int n) {//判断是否是素数,是原创 2013-04-21 17:33:05 · 651 阅读 · 0 评论 -
poj1111-搜索
#include #include char maze[25][25]; int map[25][25]; int visit[25][25]; int movex[8]={0,0,1,-1,1,1,-1,-1}; int movey[8]={1,-1,0,0,1,-1,1,-1}; int m,n,s,t,l; void dfs(int a,int b) {//深度搜索 int x,y,i;原创 2013-05-04 09:17:51 · 616 阅读 · 0 评论 -
poj2488-搜索
判断给定的棋盘,马是否能遍历完所有的点,能遍历完就打印路径,否则输出不可能! 代码: #include #include int movex[8]={-2,-2,-1,-1,1,1,2,2}; int movey[8]={-1,1,-2,2,-2,2,-1,1};//这个顺序不能变 int flag;//是否可能的标志量 int a,b;//给定棋盘大小 int pathx[26],path原创 2013-05-04 21:21:44 · 693 阅读 · 0 评论