摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1239题意:a.给定整数m,a,b(4 < m <= 100000 and 1 <= a <= b <= 1000)b.需要找到两个数(不妨设为p,q)满足以下条件: l p,q均为质数; l p*q<=m; l a/b <= p/q <= 1; c.输出所有满足以上条件的p,q中乘积最大的一对p,q 分析:考虑大于10000的某个质数,不妨设为Q,另一个质数为P,则:l如果P<10,P/Q<0.001 l如果P>10,P*Q>10000 阅读全文
posted @ 2011-03-22 22:38 CoderZhuang 阅读(139) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1372给定棋盘上的两个点,求马从起点走到终点所需的最小步数,马的走法如下(和象棋差不多),本题也是简单的BFS搜索。#include <stdio.h>#include <iostream>#include <queue>using namespace std;int xf,yf,xt,yt,ans;int dir[8][2]={{-2,1},{2,1},{-2,-1},{2,-1},{-1,2},{1,2},{-1,-2},{1,-2}};bool visited[9][ 阅读全文
posted @ 2011-03-22 20:26 CoderZhuang 阅读(116) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1312二维图:.:黑砖#:红砖@:起点求由起点最多能找到多少个黑砖,当然红砖是不能走的(上下左右四个方向);基础的搜索题,深搜或广搜都可。深搜:#include <stdio.h>#include <iostream>using namespace std;char map[21][21];int co,ro,ans;int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};bool judge(int x,int y){ if(x<0||y<0| 阅读全文
posted @ 2011-03-22 18:40 CoderZhuang 阅读(88) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1072二维图:0:墙1:路2:起点3:终点4:可重设炸弹定时器的地方,时间又重设为6。要在6个单位时间内从起点走到终点,不过当走到“ 4”时时间又可设为6;输出可行的最短步数。#include<stdio.h>#include<stdlib.h>#include<queue>#include<string.h>#include <iostream>using namespace std;int map[10][10],tim[10][10];int 阅读全文
posted @ 2011-03-22 16:57 CoderZhuang 阅读(128) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1242一个二维表:.:路#:障碍a:要救的人r:去找的人(有多个)x:门卫找人中若遇到门卫要多花一个单位的时间本题可以反过来做,用a去找最近的r; 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<queue> 4 #include<string.h> 5 #include <iostream> 6 using namespace std; 7 char map[201][201]; 8 int 阅读全文
posted @ 2011-03-22 12:18 CoderZhuang 阅读(183) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1241给一个二维图*:缺乏油的地方;@:有油的地方;当@与@之间相邻(水平,垂直,对角线八个方向都可),算同一个油田。求最多有多少个油田;#include <stdio.h>#include <string.h>#include<stdlib.h>#include <cmath>#include <iostream>using namespace std;#define MAXSIZE 103int dir[8][3]={{1,0},{-1,0},{ 阅读全文
posted @ 2011-03-22 10:48 CoderZhuang 阅读(165) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1240N表示三维图的大小(x,y,z为零到N-1),然后是一个三维图,最后是起点和终点的座标。答案输出N和从起点到终点走的步数。和hdu1253差不多的题目,并且本题不用剪技,直接BFS搜一遍就可以了。#include<stdio.h>#include<stdlib.h>#include<queue>#include<string.h>#include <iostream>using namespace std;char map[11][11][11 阅读全文
posted @ 2011-03-22 09:42 CoderZhuang 阅读(137) 评论(0) 推荐(0) 编辑