摘要: 题目链接:http://poj.org/problem?id=1979思路分析:使用DFS解决,与迷宫问题相似;迷宫由于搜索方向只往左或右一个方向,往上或下一个方向,不会出现重复搜索;在该问题中往四个方向搜索,会重复搜索,所以使用vis表来标记访问过的点,避免重复搜索。代码如下:#include u... 阅读全文
posted @ 2014-10-12 19:53 Leptus 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3984思路:经典型的DFS题目。搜索时注意剪枝:越界处理,不能访问处理。代码:#include using namespace std;const int MAX_N = 15;int map[MAX_N][MAX_N];typedef... 阅读全文
posted @ 2014-10-12 18:18 Leptus 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2363思路分析:由于数据较小,采用暴力搜索法。假设对于矩形边长 1 using namespace std;int main(){ int n, min_area; double a, b, c, volume; ci... 阅读全文
posted @ 2014-10-12 13:21 Leptus 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2245思路分析:无重复元素组合组合问题,使用暴力枚举法,注意剪枝条件。代码如下:#include using namespace std;const int MAX_N = 15;int n, k = 6;int Set[MAX_N],... 阅读全文
posted @ 2014-10-12 12:38 Leptus 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1731思路分析:含有重复元素的全排列问题;元素个数为200个,采用暴力枚举法。代码如下:#include #include using namespace std;const int MAX_N = 200 + 10;void Prin... 阅读全文
posted @ 2014-10-12 01:27 Leptus 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1256思路分析:该题为含有重复元素的全排列问题;由于题目中字符长度较小,采用暴力法解决。代码如下:#include #include using namespace std;const int MAX_N = 20;char P[MAX... 阅读全文
posted @ 2014-10-12 01:01 Leptus 阅读(213) 评论(0) 推荐(0) 编辑