![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dp
苯上的甲基
仅供自学使用,出了事情概不负责xD
展开
-
LeetCode 45 跳跃游戏Ⅱ
题目要求跳到最后一个元素的最小次数。然而对于跳到每一个元素的次数,是由前面N个能跳到该元素的次数+1决定的。(x[i]+ 1),但是前面有多少个能跳到本元素呢,不知道,所以只能正向动态规划。动态规划数组dp【i】,表示能到第i个位置的最少次数。题目给的数组nums【i】,为第i个位置能跳跃的最大距离。所以很容易的可以得出状态转移方程:dp [i + x] = min(dp[i + x],dp[i] + 1) 0<=x<=nums[i]给出Leetcode代码和编译器代码LeetC原创 2022-04-16 17:22:25 · 2490 阅读 · 0 评论 -
Proud Merchants 01背包
K - Proud MerchantsRecently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still v...原创 2019-11-06 20:42:21 · 104 阅读 · 0 评论 -
m段的最大和(动态规划)
Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem. Given...原创 2018-10-18 20:39:31 · 326 阅读 · 0 评论 -
UVA 624 CD 01背包加路径记录问题
其实按照题目来后 我们直接可以写一个裸的01背包,但是就是路径不知道怎么记录。我们知道动态规划的本质就是用空间换时间的方法,所以他是一个表。我们可以开一个vis的二维数组表,把算出来的值记录进去。然后把vis数组倒着遍历一遍就可以了。为什么要倒着,应为我们dp表中有很多算出来的中间值不一定是我们要求的最优值,但是我们最后用01背包算出来的值肯定是最优值,我们把算出来的最优值减去val数...原创 2019-04-20 21:38:52 · 147 阅读 · 1 评论 -
hdu 2577 DP
How to TypeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8642Accepted Submission(s): 3797Problem DescriptionPirates have finis...原创 2019-07-31 14:49:11 · 94 阅读 · 0 评论 -
hdu 2069 完全背包dp
A -Coin ChangeTime Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionSuppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, an...原创 2019-08-19 22:59:08 · 198 阅读 · 0 评论 -
概率dp hdu2599
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the lucrative...原创 2019-08-13 11:53:33 · 106 阅读 · 0 评论