
背包
文章平均质量分 71
BEconfidence
坚持才是胜利之道
展开
-
HDU4508:湫系列故事——减肥记I(完全背包)
#include #include using namespace std; int sum=0; void getMax(int N,int ** array,int Limit,int happiness) { if(Limit==0) { if(happiness > sum) sum = happiness; return; }原创 2015-06-14 23:45:08 · 513 阅读 · 0 评论 -
hdu Bone Collector(背包)
二位数组做法; #include #include #define M 1009 typedef struct pack { int cost; int val; }PACK; int f[M][M];#include #include #define M 1009 typedef struct pack { int cost; int val; }PACK; i原创 2015-06-14 20:47:29 · 534 阅读 · 0 评论 -
hdu 1114 Piggy-Bank(完全背包)
#include #include #include using namespace std; const int INF = 99999999; int c[50005],w[10005]; int bag[10005]; int N,V,Z; void _com_bag() { int i,j; for(i=0;i<=Z;i++) bag[i]=INF; bag[0]=原创 2015-06-14 21:57:46 · 604 阅读 · 0 评论 -
HDU 2191 珍惜现在,感恩生活 (多重背包)
#include #include using namespace std; struct rice{ int p; int h; }rice[505]; int max(int a,int b) { return a>b?a:b; } int main() { int t,n,m,p,h,c,i,j,f[101],k; cin>>t; while(原创 2015-06-14 22:08:12 · 787 阅读 · 0 评论 -
hdu 2159 FATE 二维背包
先求出不超过他的忍耐度杀完s只怪时能够得到的经验值, 如果能升完最后一级,再求用去多少忍耐度就能够升级,最后用他的忍耐度减去需要消耗的忍耐度即可 /*忍耐度当做体积,经验值当做价值,怪的只数当做物品数量*/ 状态转移方程:f[i][j]=max{f[i][j],f[i-b][j-1]+a} i表示忍耐度,j表示杀怪数/*忍耐度当做体积,经验值当做价值,怪的只数当做物品数量*/ #include #原创 2015-06-14 23:59:05 · 457 阅读 · 0 评论