上一页 1 ··· 9 10 11 12 13 14 15 下一页
摘要: 题目链接: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 阅读(233) 评论(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 阅读(253) 评论(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 阅读(170) 评论(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 阅读(200) 评论(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 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1159思路分析:对该问题的最优子结构与最长回文子序列相同。根据最长回文子序列的状态方程稍加改变就可以得到该问题动态方程。假设字符串为A[0, 1, ..., n],则定义状态dp[i, j]表示字符串A[i, i+1, ..., j]成... 阅读全文
posted @ 2014-10-11 01:55 Leptus 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3624思路分析:经典的0-1背包问题:分析如下:代码如下:#include using namespace std;const int MAX_N = 12880 + 10;int dp[MAX_N], W[MAX_N], D[MAX_... 阅读全文
posted @ 2014-10-11 00:28 Leptus 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1458思路分析:经典的最长公共子序列问题(longest-common-subsequence proble),使用动态规划解题。1)问题定义:给定两个序列X=和Y = ,要求求出X和Y长度最长的最长公共子序列;2)问题分析: ... 阅读全文
posted @ 2014-10-10 23:20 Leptus 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2250思路分析:最长公共子序列问题的变形,只是把字符变成了字符串,按照最长公共子序列的思路即可以求解。代码如下:#include #include #define IsEqual(a, b) strcmp((a), (b)) == 0e... 阅读全文
posted @ 2014-10-10 22:42 Leptus 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2346思路分析:使用动态规划解法:设函数 d( n, x )代表长度为n且满足左边n/2位的和减去右边n/2位的和为x的数的数目。将一个长度为n的数看做n个数字 A1, A2....An ( 0 #include #include co... 阅读全文
posted @ 2014-10-10 02:19 Leptus 阅读(255) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 下一页