
动态规划
文章平均质量分 65
Mind_V
这个作者很懒,什么都没留下…
展开
-
动态规划——0-1背包问题
问题描述给定n种物品和一背包。物品i的重量是wi,其价值为vi,背包的容量为C。问:应如何选择装入背包的物品,使得装入背包中物品的总价值最大?算法设计分析背包问题要求达到物品总价值的最优化,每一次选择作为一个阶段,根据前一个阶段的解可以求解出后一个阶段的解。定义状态F[i,y],表示剩余容量为y,剩余物品为i, i+1, i+2 ,…, n的最优解。所以:(2)式便是状态转移方程,而(1)式则是边界原创 2017-08-31 08:55:50 · 2381 阅读 · 0 评论 -
动态规划
算法思想dynamic programming is a method for solving a complex problem by breaking it down into a collection of simpler subproblems.——维基百科动态规划的思想:将待求解的问题分解为若干个子问题(阶段),按顺序求解子阶段,前一子问题的解,为后一子问题的求解提供了有用的信息。在求解任原创 2017-08-29 22:25:20 · 943 阅读 · 1 评论 -
Perfect Squares——动态规划
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4;原创 2017-10-18 10:14:28 · 477 阅读 · 0 评论 -
Word Break Ⅱ
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. You may assume the dictionary does原创 2017-09-29 13:11:23 · 739 阅读 · 1 评论