![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划
文章平均质量分 88
您还不是尊贵的会员身份
这个作者很懒,什么都没留下…
展开
-
POJ 1163 The Triangle数塔 动态规划
The Triangle7 3 8 8 1 0 2 7 4 4 4 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on ...原创 2017-12-08 09:41:57 · 156 阅读 · 0 评论 -
动态规划之最长上升子序列 HDU1950
最长上升子序列问题求的是形如一个数列a={4,2,3,1,5},那么这个数列的最长上升子序列就是{2,3,5}求解这种问题有两种方法,第一种是求当前元素之前元素的最长上升子序列,得到递推公式dp[i]=max(1,dp[j]+1)意思是仅当前元素或者前一元素递推得到的最长上升子序列+当前元素,第二种是求相等长度的上升子序列,最后一个元素越小,则该子序列的“上升潜力”越大。方法一:int dp[ma...原创 2018-01-28 23:13:49 · 249 阅读 · 0 评论 -
HDU-1114 Piggy-Bank 完全背包的灵活运用
Piggy-BankBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behi...原创 2017-12-06 22:34:38 · 335 阅读 · 0 评论 -
HDU-2602 Bone Collector 01背包
Bone CollectorProblem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he we...原创 2017-12-06 20:37:55 · 134 阅读 · 0 评论 -
01背包模板和完全背包模板
01背包#include<bits/stdc++.h>using namespace std;int f[100];//背包容积int V;//背包容积int n;//物品数int w[100],c[100];//物品价值&体积int work(){ for(int i=1;i<=n;++i) for(int v=V;v>=c[i]...原创 2017-12-05 23:41:19 · 556 阅读 · 0 评论 -
01背包方案计数
状态转移方程:F[j]=F[j]+F[j-G[i]]#include<bits/stdc++.h>using namespace std;int hav[150];int val[150];int dp[20009];int n,v; int ans=0;int solve(){ for(int i=1;i<=n;i++) for(...原创 2018-04-30 23:38:11 · 494 阅读 · 0 评论 -
2018-Summer之区间dp
区间dp什么是区间dp: 区间dp是解决区间上的一类动态规划问题的方法,例如区间合并、区间符号配对等等,其思想是将大区间分成小区间,结合动态转移方程来求小区间的最优解,最终合并成大区间的最优解区间dp的一般思路 1.确定dp数组初始值 2.确定转移方程 3.枚举区间、分割点 4.dp[1][N]一般是最后答案 5.区间dp的复杂度一般为n^2,数据规模为几百区间dp的一般模...原创 2018-09-02 00:33:16 · 255 阅读 · 0 评论