动态规划
文章平均质量分 72
WsAllk
这个作者很懒,什么都没留下…
展开
-
Dynamic Programming
Question 1 : Rob-Cutting Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n.Determine the maximum value obtainable by cutting up the rod...原创 2019-10-17 09:38:45 · 142 阅读 · 0 评论 -
钢条切割问题——动态规划
基本原理:将钢条从长度为1至N依次分隔成两部分,例如分成1和N-1,2和N-2等,分割完后左半部分价格已经确定,则只需要计算右半部分(例如N-1,N-2)长度的钢条价格,而这又是一个子问题,故想到用递归来解决自顶向下递归代码实现如下int CutRod(int p[],int n){ if(n==0) return 0; int q=-1; for(int i=0;i<n...原创 2018-06-01 21:23:06 · 580 阅读 · 0 评论