ADS Assignment of DP
Dynamic Programming
- Rod-cutting Problem: Given a rod of total length N inches and a table of selling prices P L P_L PL for lengths L=1,2,⋯,M. You are asked to find the maximum revenue R N R_N RN obtainable by cutting up the rod and selling the pieces. For example, based on the following table of prices, if we are to sell an 8-inch rod, the optimal solution is to cut it into two pieces of lengths 2 and 6, which produces revenue R 8 = P 2 + P 6 = 5 + 17 = 22 R_8=P_2+P_6=5+17=22 R8=P2+P6=5+17=22. And if we are to sell a 3-inch rod, the best way is not to cut it at all.
Length L | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|---|---|---|---|---|---|---|---|---|---|
Price P L P_L PL | 1 | 5 | 8 | 9 | 10 | 17 | 17 | 20 | 23 | 28 |
Which one of the following statements is FALSE?
A. This problem can be solved by dynamic programming
B. The time complexity of this algorithm is O ( N 2 ) O(N^2) O(N2)
C. If N≤M, we have R N = m a x ( P N , m a x 1 ≤ i < N ( R i + R N − i ) ) R_N=max(P_N,max_{1≤i<N}(R_i+R_{N−i})) RN=max(PN,max1≤i<N(Ri+RN−i))
D. If N>M, we have R N = m a x 1 ≤ i < N ( R i + R N − M ) R_N=max_{1≤i<N}(R_i+R_{N−M}) RN=max1≤i<N(Ri+RN−M)
分析:
对于任意一根长度为L的钢管,如果最优解包括一段长度为5的钢管,那么切下5单位长度后的钢管的最优解也是长度为L-5的钢管最优解。
问题的最优解包含相关子问题的最优解,这些子问题我们可以独立求解。
所以我们可以用动态规划的方式写这道题,递推关系式应该是
当 N > M N\gt M N>M, R N = m a x 1 ≤ i < N ( R i + R N − i ) R_N=max_{1≤i<N}(R_i+R_{N−i}) RN=max1≤i<N(Ri+RN−i)
当 N ≤ M N\le M N≤M, R N = m a x ( P N , m a x 1 ≤ i < N ( R i + R N − i ) ) R_N=max(P_N,max_{1≤i<N}(R_i+R_{N−i})) RN=max(PN,max1≤i<N(Ri+RN−i))
问题规模是指数级别的,所以选D.
- In dynamic programming, we derive a recurrence relation for the solution to one subproblem in terms of solutions to other subproblems. To turn this relation into a bottom up dynamic programming algorithm, we need an order to fill in the solution cells in a table, such that all needed subproblems are solved before solving a subproblem. Among the following relations, which one is impossible to be computed?
解题思路
- Given a recurrence equation f i , j , k = f i , j + 1 , k + m i n 0 ≤ l ≤ k ( f i − 1 , j , l + w j , l ) f_{i,j,k}=f_{i,j+1,k}+min_{0≤l≤k}(f_{i−1,j,l}+w_{j,l}){} fi,j,k=fi,j+1,k+min0≤l≤k(fi−1,j,l+wj,l). To solve this equation in an iterative way, we cannot fill up a table as follows:
此题相当于给定计算顺序,判断是否合理.(答案选B)
ADS Assignment of DP相关推荐
- [UVALive 7143]Room Assignment(Dp)
Description There are N guests checking in at the front desk of the hotel. 2K (0 ≤ 2K ≤ N) of them a ...
- Codeforces Round #633 B. Edge Weight Assignment 结论题 + dp
传送门 文章目录 题意: 思路: 题意: 思路: 首先考虑最小值,如果从一个叶子结点出发到任意叶子的距离都为偶数,那么只需要一个值就可以满足条件.如果有奇数的,考虑111 ^ 222 ^ 3=03=0 ...
- HITOJ 2662 Pieces Assignment(状压DP)
Pieces Assignment My Tags (Edit) Source : zhouguyue Time limit : 1 sec Memory limit : 64 M S ...
- UVALive 7143 Room Assignment(组合数学+DP)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...
- tcp转串口_PROFIBUS DP与Modbus/TCP网络转换操作指南
>>PROFIBUS DP转Modbus/TCP网关操作指南 摘要: 本文以NT100-RE-DP网关为例,实现Modbus/TCP Client与PROFIBUS DP设备间的通讯,从而 ...
- [入门向选讲] 插头DP:从零概念到入门 (例题:HDU1693 COGS1283 BZOJ2310 BZOJ2331)
转载请注明原文地址:http://www.cnblogs.com/LadyLex/p/7326874.html 最近搞了一下插头DP的基础知识--这真的是一种很锻炼人的题型-- 每一道题的状态都不一样 ...
- 8.12模拟:dp递推
文章目录 前言 本次最大收获 考场 复盘 T1 lecture T2 n-thlon T3 assignment T4 recoverset 总结 前言 245分 100+70+40+35 不太满意q ...
- 【HDU - 4784】Dinner Coming Soon(记忆化搜索bfs,dp)
题干: Coach Pang loves his boyfriend Uncle Yang very much. Today is Uncle Yang's birthday, Coach Pang ...
- HOJ-2662Pieces Assignment(状态压缩,动态规划)
Pieces Assignment Source : zhouguyue Time limit : 1 sec Memory limit : 64 M Submitted : 415, Accepte ...
最新文章
- javascript内置顶层函数
- 用Java实现几种常用排序算法(先实现一个org.rut.util.algorithm.SortUtil)
- Anacanda的安装
- matlab 行 读取文件 跳过_用Matlab处理LAS点云(1)——LAS文件概述
- 花痴流口水颜文字_流口水可执行模型
- C语言中执行python代码或源程序文件(高级嵌入方式)
- 【算法设计】最大子段和问题解析(对应算法第三题)
- Windows 进程管理
- python获取参数
- macOS 常用字体下载安装
- 项目管理之敏捷开发之道
- 2022年3月显示器主观科普与配置选型
- 当 SegmentFault 遇上呼伦贝尔
- 戴尔计算机管理界面在哪里,戴尔 win10系统控制面板如何打开?
- 关于全球时间的一点理解
- 山西大学 计算机科学,李德玉 - 山西大学 - 计算机与信息技术学院
- python:考试前,练手习题(斐波那契数,字符串排序,九九乘法表,水仙花数,求和...求数字倍数,(保佑不挂科!)
- Markdown Flow 画流程图详解
- 来华留学生统计数据集(2018-2019年)
- 快消行业营销难?巨量引擎让生意每一步明明白白