2014年12月16日

hdu1495(bfs)

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1495题意:有三个杯子,开始时第一个杯子装满水(体积为a),倒来倒去,得到其中2个杯里的水的体积都为a/2,求最小次数,不存在就输出NO。分析:因为被子没有刻度,所以倒入时要倒满或倒完才能保证知道容积,即... 阅读全文

posted @ 2014-12-16 23:16 lienus 阅读(211) 评论(0) 推荐(0)

hdu1254(bfs+dfs)

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1254分析:真正移动的是箱子,但是要移动箱子需要满足几个条件。1.移动方向上没有障碍。2.箱子后方没有障碍。3.人可以到达箱子后方的地方。这里dfs或bfs都可以实现按条件搜索即可。#include #i... 阅读全文

posted @ 2014-12-16 22:55 lienus 阅读(150) 评论(0) 推荐(0)

poj3126(bfs)

摘要: 题目链接:http://poj.org/problem?id=3126题意:给两个四位数n,m,将n变成m需要多少步,要求每次只能改变n的某一位数,即改变后的数与改变前的数只有一位不同,且每次改变后的数都是素数。分析:筛选素数+bfs,枚举每一位数字进行修改,修改后还是素数的进入队列,循环出队入队,... 阅读全文

posted @ 2014-12-16 20:33 lienus 阅读(350) 评论(0) 推荐(0)

poj3278(bfs)

摘要: 题目链接:http://poj.org/problem?id=3278分析:广搜,每次三种情况枚举一下,太水不多说了。#include #include #include #include #include #include #include #include #include #include #... 阅读全文

posted @ 2014-12-16 17:51 lienus 阅读(126) 评论(0) 推荐(0)

poj3984(经典dfs)

摘要: 题目链接:http://poj.org/problem?id=3984分析:直接深搜从起点到终点,如何取最短路线,其实只要优先向下或向右走即可。#include #include #include #include #include #include #include #include #inclu... 阅读全文

posted @ 2014-12-16 17:44 lienus 阅读(305) 评论(0) 推荐(0)

fzu2150(bfs)

摘要: 题目链接:http://acm.fzu.edu.cn/problem.php?pid=2150题意:在任意两处点火,求最短时间烧光所有草堆。分析:由于n,m比较小,将所有草堆坐标记录下来,然后暴力枚举所有可能的两处草堆为起点燃烧。最后取最短时间。求每两处燃烧需要用的时间一次bfs即可。#includ... 阅读全文

posted @ 2014-12-16 16:50 lienus 阅读(167) 评论(0) 推荐(0)

zoj1940(三维广搜)

摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=940分析:三维其实就是六个方向地搜索,思维清晰且细心点,很快就AC了。#include #include #include #include #include #incl... 阅读全文

posted @ 2014-12-16 15:21 lienus 阅读(246) 评论(0) 推荐(0)

导航