
0-1背包
Kira~~
梦想还是要有的,万一实现了呢~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
优先队列式分支限界法求解0-1背包问题
优先队列式分支限界法求解0-1背包问题#include <iostream>#include <cstdlib>#include <queue>#include <vector>using namespace std;#define n 4int w[n]= {3,5,2,1},v[n]= {9,10,7,4},x[n]= {0};i...原创 2019-12-01 16:01:00 · 2452 阅读 · 3 评论 -
队列式分支限界法求解0-1背包问题
队列式分支限界法求解0-1背包问题#include <iostream>#include <cstdlib>#include <queue>using namespace std;#define n 4int w[n]={3,5,2,1},v[n]={9,10,7,4},x[n]={0};int W=7;double cw=0,cp=0,best...原创 2019-12-01 11:19:34 · 2482 阅读 · 2 评论 -
回溯法求解0-1背包问题
回溯法求解0-1背包问题#include <iostream>#include <cstdlib>using namespace std;int x[4]={0},y[4]={0};double w[4]={3,5,2,1},v[4]={9,10,7,4},DV[4]={0};int n=4,W=7,bestp=0,cp=0,cw=0;struct Dvalu...原创 2019-11-30 18:51:49 · 491 阅读 · 1 评论 -
动态规划法求解0-1背包问题2(改进算法)
动态规划法求解0-1背包问题2(改进算法)#include <iostream>#include <algorithm>using namespace std;int p[1000][1000];//p存放跳跃点集合,第一列存放物品的质量w,第二列存放物品的价值vint x[5]= {0},head[100];//head是指向各个阶段跳跃点集合的开始int W...原创 2019-11-26 12:32:28 · 1180 阅读 · 0 评论 -
动态规划法求解0-1背包问题
动态规划法求解0-1背包问题#include <iostream>#include <algorithm>using namespace std;int W=10,x[100]={0};int C[100][100];int KnapSack(int n,int w[],int v[])//物品个数n,物品的价值v[n]和物品的重量w[n]{ for(...原创 2019-11-26 09:55:35 · 343 阅读 · 0 评论