动态规划
文章平均质量分 58
ych_ding
这个作者很懒,什么都没留下…
展开
-
POJ 3211洗衣服
#include #include using namespace std; struct clrg { char color[16]; int sum; int i; int a[100]; }; static int dp[100001]; //#define DEBUG int main() { #ifdef DEBUG fstream cin("G:\\book\\al原创 2013-09-30 09:32:50 · 717 阅读 · 0 评论 -
POJ 1260
#include #include #include using namespace std; //#define DEBUG /* 244K 0MS */ static const int MAX = 101; static int count[MAX]; static int price[MAX]; static int presum[MAX]; static int n; static原创 2013-10-02 15:49:20 · 829 阅读 · 0 评论 -
leetcode 字符串交织
问题描述: https://oj.leetcode.com/problems/word-break/点击打开链接 Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more diction原创 2014-11-29 19:06:29 · 824 阅读 · 0 评论 -
leetcode edit-distance
问题描述: https://oj.leetcode.com/problems/edit-distance/点击打开链接 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 st原创 2014-12-05 22:44:38 · 390 阅读 · 0 评论 -
leetcode palindrome-partitioning
问题描述: https://oj.leetcode.com/problems/palindrome-partitioning-ii/点击打开链接 Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed原创 2014-12-06 20:14:35 · 286 阅读 · 0 评论 -
POJ 1159 如何构造回文序列
#include #include using namespace std; static int n; static const int N = 5001; static char str[N]; static char rstr[N]; static int c[N][N]; //#define DEBUG int lcs() { int i, j; for (i = 0; i <原创 2013-09-18 09:56:35 · 823 阅读 · 0 评论 -
POJ 2533 最长递增子序列
#include #include using namespace std; //#define DEBUG static const int MAX = 1001; static int seq[MAX]; static int f[MAX]; int main() { #ifdef DEBUG fstream cin("G:\\book\\algorithms\\acm\\Debug原创 2013-09-02 21:14:54 · 684 阅读 · 0 评论 -
找零问题
问题描述: 有n种面值货币,给定一个钱的数目x,要求最少的货币数目表示。 问题分析: 该问题看似像贪心,先选用面值大的货币,再选用面值小的货币。 实际并不具备贪心选择的性质。使用贪心不能确保得到最优解。 定义: f(x) 表示x所需要的最小货币数目 a[n] n种面值 推导: f(x) = min { f(x - a[i]) } 任意i 使得 x - a[i] >=0原创 2014-11-27 22:30:01 · 1167 阅读 · 1 评论 -
poj3624 0-1背包问题
#include #include using namespace std; static const int N = 3403; static const int M = 12881; static int f[N][M]; static int c[N], v[N]; //#define DEBUG int main() { #ifdef DEBUG fstream cin("G:\原创 2013-09-23 13:16:41 · 6329 阅读 · 0 评论