![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
acm(DP类)
题目
不会编程怎么行
fighting
展开
-
01背包
https://www.cnblogs.com/aiguona/p/7274222.html原创 2020-01-13 20:07:54 · 85 阅读 · 0 评论 -
B - 饭卡
转自: https://www.cnblogs.com/blvt/p/7359829.html网上分析:设余额为m,令s=m-5,那么我们就要找使得容量为s的背包最后剩的空间最小的方法,找到之后再用这个剩余容量+5-最大的那个没有被选的商品价值就是最小余额.但是现在我们不知道最后需要减的那个物品应该是哪个,可以证明最后需要减的那个物品一定是价值最大的那个.证明:假设价值最大的为max,且...转载 2020-01-13 20:04:15 · 158 阅读 · 0 评论 -
最长公共子序列问题
首先要明白什么是公共子序列这个题便是用到了下面这样的方法,这也算是一类题的方法例如输入:abcbdbacbbabdbb动笔写一写会是什么样的一个动态矩阵????还是不懂的话看眼代码吧!!!#include<bits/stdc++.h>using namespace std;int main(){ char str1[501], str2[5...原创 2019-12-04 21:57:49 · 97 阅读 · 0 评论 -
Divisibility(动态规划,加一些数论)
Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different values. Let us,...原创 2020-02-25 22:08:19 · 119 阅读 · 0 评论 -
Proud Merchants(特殊的01背包)
Recently, 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 very proud even if their nation hasn’t been so wealthy any more.The merchants we原创 2020-04-24 21:01:16 · 274 阅读 · 0 评论 -
G-字符串?(求构成回文字符串的最少插入多少字符)
分析:求字符串s和字符串s的逆序是s1的最长公共字符串长度,用总长度减去最长公共字符串的长度就是所有方案中添加字符最少的#include<bits/stdc++.h>using namespace std;const int N = 1e4+10;int dp[N][N];int main(){ char s[N],s1[N]; int j = 0; ...原创 2020-05-05 16:59:02 · 173 阅读 · 0 评论 -
最长上升子序列 (LIS) 详解+例题模板 (全)
最长上升子序列详解下面是一个例题:#include<bits/stdc++.h>using namespace std;int main(){ int a[1100]; int n; int dp[1100]; cin>>n; for(int i=0; i<n; i++) { cin>&...原创 2020-05-05 21:23:55 · 359 阅读 · 0 评论