钢条分割 动态规划java_动态规划-钢条切割问题

Description:

The rod-cutting problem is the following. Given a rod of length n inches and a table of prices pi for i D 1,2,…,n, determine the maximum revenue rn obtainable by cutting up the rod and selling the pieces. Note that if the price pn for a rod of length n is large enough, an optimal solution may require no cutting at all.

以下给出的样例:

3ca355b498ca0a3ec6518d7b6fe7ff68.png

Analysis:

长度为n的钢条可以有2n-1中切割方案,所以当n很大时用暴力求解的方法是行不通的。假设将该钢条切割成k(k的取值为[1,n])段,切割顺序为从钢条的左端开始,那么最有切割方案是:

n = len1+len2+len3+…+lenk

将钢条切割为长度是len1,len2,…,lenk的小段,得到最大收益

rn = p len1+plen2+plen3+…+plenk

根据样例给出的价格表,可以得到最大收益值ri(i=1,2,…,10)及对应的切割方案。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值