码迷,mamicode.com
首页 >  
搜索关键字:dp    ( 24588个结果
算法训练-Don't fear, DravDe is kind
#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]; //方法:使用一维数... ...
分类:编程语言   时间:2020-06-06 22:02:23    阅读次数:68
二进制优化多重背包
#include using namespace std; const int maxn=1000+10; int n,k,w[maxn],v[maxn],dp[11*maxn]={0},nw[11*maxn],nv[11*maxn],cnt=0,c[maxn]; //01背包二进制拆分 //普通拆... ...
分类:其他好文   时间:2020-06-06 22:01:03    阅读次数:85
背包输出方案数
#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,做辅助数组,因为重复只会发生在d... ...
分类:其他好文   时间:2020-06-06 22:00:44    阅读次数:52
二叉苹果树
#include using namespace std; //二叉苹果树 //j代表保留树枝的总数 //做法一:当j大于子树所能保存的最大的边的时候,值都是最大的边对应的值,导致肯定没有刚好分配边数的值大 int n,dp[110][110]={0},G[100+10][100+10],k,son... ...
分类:移动开发   时间:2020-06-06 21:55:58    阅读次数:76
271. 杨老师的照相排列
#include using namespace std; typedef long long ll; ll dp[32][32][32][32][32],n,k[5]; //枚举最后一个编号最大的同学的位置,DP代表着abcde及这么多个人的总数,那么a-1bcde的总数也可求得 ll DP(in... ...
分类:其他好文   时间:2020-06-06 21:53:40    阅读次数:99
二维背包
#include using namespace std; const int N=100+10; //二维代价的背包问题,就是dpi,j,k 太大了,用滚动数组 //注意滚动数组倒着遍历j int n,dp[N][N]={0},w[N],m[N],v[N],V,M; int main() { ci... ...
分类:其他好文   时间:2020-06-06 21:52:58    阅读次数:61
算法训练方格取数
#include using namespace std; // 走两次是不行的,因为这就是贪心了。。 // 需要多线程dp,就是想象有2个人同时走,他们可以走到一起,但是必须只加一次; // 转移方程: // (1)a,b都从上/下走过来 // (2)a,b一个上一个下走过来 // 共4种 //d... ...
分类:编程语言   时间:2020-06-06 21:42:53    阅读次数:68
哈密顿回路
#include<bits/stdc++.h> using namespace std; //状态压缩dp,二进制法,搜索法的优化 int dp[1<<20][21],n;//最多20个点,就是20位二进制 //在状态是i,末位点是j的情况下的最小值(因为状态没有顺序信息,但是其实只需要知道末尾点即... ...
分类:其他好文   时间:2020-06-06 21:35:25    阅读次数:73
传纸条
#include using namespace std; //和方格取数一样,一来一回可以看成走两次 int a[51][51],m,n,dp[51][51][51][51]={0}; int main() { cin>>m>>n; for(int i=1;i>a[i][j]; for( int ... ...
分类:其他好文   时间:2020-06-06 21:32:36    阅读次数:85
加分二叉树
#include using namespace std; //加分二叉树 int n,dp[40][40]={0},a[40],ans=0,root[40][40]; void f(int i,int j){ if(i>j) return; cout>n; for(int i=1;i>a[i]; ... ...
分类:其他好文   时间:2020-06-06 21:27:21    阅读次数:60
24588条   上一页 1 ... 58 59 60 61 62 ... 2459 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!