![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
文章平均质量分 73
Sylvia的三个月突击史
这个作者很懒,什么都没留下…
展开
-
HDOJ 1003 Max Sum(动态规划)
Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4原创 2018-01-24 15:09:21 · 131 阅读 · 0 评论 -
递推问题
递推问题主要涉及到两大类,背过方法即可1. 普通递推(爬楼梯问题)2. 错排问题 :运用错排公式 F[N]=(N-1)*F[N-1]+(N-1)*F[N-2]例一:九度1205题目描述:N阶楼梯上楼问题:一次可以走两阶或一阶,问有多少种上楼方式。(要求采用非递归)输入:输入包括一个整数N,(1<=N<90)。输出:可能有多组测试数据,对于每组数据,输出当楼梯阶数是N时的上楼方式个数。样...原创 2018-03-24 10:28:30 · 807 阅读 · 0 评论 -
最长递增子序列LIS
<动态规划进阶啦>在已知序列中,取出若干数组成新的序列,这个序列下标和大小要按照从小到大或者从大到小的顺序,找出最长子序列。F[1]=1;F[i]=max{1, F[j]+1 | aj<ai && j<i };for (i = n-1; i >=0; i--) { dp2[i] = 1; for (j = n-1; j >i; j--...原创 2018-03-24 23:13:12 · 129 阅读 · 0 评论 -
背包问题
动态规划中运用非常多的是背包问题背包问题一共有三种:1. 0-1背包问题2. 完全背包问题(需要把背包装满,只需要在0-1背包的基础上改变一下初始化即可)3. 多重背包问题(相当于0-1背包问题的演变)例一 九度1123 0-1背包问题题目描述:辰辰是个很有潜能、天资聪颖的孩子,他的梦想是称为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带...原创 2018-03-31 11:40:40 · 136 阅读 · 0 评论 -
最长公共子序列LCS
此类问题一般是给出两个或多个字符串,然后找出最长的相同子序列。方法(两个字符串为例):dp[0][i]=0 i∈[0,length(str1)]dp[i][0]=0 i∈[0,length(str2)]dp[i][j]=dp[i-1][j-1]+1 (str1[i] == str2[j])dp[i][j]=max(dp[i-1][j],dp[i][j-1]) (str1[i] != str2[...原创 2018-03-26 11:30:10 · 97 阅读 · 0 评论 -
动态规划poj练习
poj 3176 Cow BowlingDescriptionThe cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle l...原创 2018-04-09 13:24:15 · 193 阅读 · 0 评论