摘要: #include using namespace std; const int maxn=1000+10,mod=1e9+7; int n,k,w[maxn],v[maxn],dp[maxn][maxn]={0},c[maxn][maxn]; //思路,开一个数组c,做辅助数组,因为重复只会发生在dp[i-1][j-w[i]]+v[i]==dp[i-1][j]的情况,所以。。 //c的含义是在最... 阅读全文
posted @ 2020-06-06 20:53 西伯利亚挖土豆 阅读(150) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; //状态压缩dp,二进制法,搜索法的优化 int dp[1<<20][21],n;//最多20个点,就是20位二进制 //在状态是i,末位点是j的情况下的最小值(因为状态没有顺序信息,但是其实只需要知道末尾点即可) //通过上个状态推出下个状态, int a[22][22]; int main() { whi 阅读全文
posted @ 2020-06-06 20:45 西伯利亚挖土豆 阅读(232) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; #define index(i) i-1 const int N=110; string a,b; //i代表a串右位置、j代表b串右位置 //比较ai bj 如果=。。。 //如果!=,那么1.假设i存在于最长中j不在;2.假设j存在于最长中i不在3.ij都不在,对123取最大值 //12包含了3 int 阅读全文
posted @ 2020-06-06 20:44 西伯利亚挖土豆 阅读(136) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; int dp[100][40000]={0},n,m,w[100],v[100],G[100][100]={0}; //算法提高,类似于机器人问题 //树形dp,用边来表示花费,设u->v那么w[v]为这条边的花费 //这个题本来是一个森林,但是我加上一个根,就变成了树,而且节点的wv转移到边上,正好 vo 阅读全文
posted @ 2020-06-06 20:44 西伯利亚挖土豆 阅读(156) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; int n,dp[100001],v[100001],c[100001],l[100001],r[100001],maxx=0,ok[100001],ll,num=0,m=0; vector hash[100000]; //方法:使用一维数组,dp[a]表示有a且以a为结尾的最大值,那么a的前后数目都确定了, //对于1::iterat... 阅读全文
posted @ 2020-06-06 20:43 西伯利亚挖土豆 阅读(244) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //算法提高,能量项链,就是可以转圈的矩阵连乘问题 //把1->n扩展为1->n->n+1->2*n,然后对其进行dp,这样就循环起来了 int dp[2000][2000],n,a[1000],ans=0;//用i表示左维度,i+1表示右维度 int main() { cin>>n; for(int i=1;i>a[... 阅读全文
posted @ 2020-06-06 20:42 西伯利亚挖土豆 阅读(207) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //部分状态转移方程有平行四边形优化 //但第三层寻找最优分割点的时候会有许多重复的过程, //这里我们可以用一个s[i][j]数组记录下从i 到 j 最优分割点的下标, 在下次寻找时减少寻找次数, //这样就可以将时间降低到 n ^ 2的复杂度, 就是平行四边形优化。 #define INF 0x7fffffff int a[10... 阅读全文
posted @ 2020-06-06 20:42 西伯利亚挖土豆 阅读(158) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; typedef long long ll; ll dp[32][32][32][32][32],n,k[5]; //枚举最后一个编号最大的同学的位置,DP代表着abcde及这么多个人的总数,那么a-1bcde的总数也可求得 ll DP(int a,int b,int c,int d,int e){ if(dp[a][b][c][... 阅读全文
posted @ 2020-06-06 20:41 西伯利亚挖土豆 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; const int maxn=100+10; //开新木板不一定要刚好一样大,可以比i大 //不开的情况不考虑,因为开了的情况因为开的大小由最大值确定,所以包含了不开的情况 //他给的测试数据有迷惑性 //这个题根据经验想到了要枚举,在根据数据发现可以多开 => 枚举最后一个木板包含的数目,并用最大值开那个木板 //可以多枚举,反正取... 阅读全文
posted @ 2020-06-06 20:41 西伯利亚挖土豆 阅读(195) 评论(0) 推荐(0) 编辑
摘要: //递推 //见https://blog.csdn.net/accelerator_/article/details/9636923 #include #include #include #include #include #include #include #include #define EPS 1e-6 using namespace std; int main(){ ... 阅读全文
posted @ 2020-06-06 20:39 西伯利亚挖土豆 阅读(130) 评论(0) 推荐(0) 编辑