摘要: 我们以HDU 1171 Big Event in HDU 为例代码来源:http://growthinking.com/archives/844 1 #include<stdio.h> 2 #include<string.h> 3 int n,v[55],num[55],all,sum,dp[250005]; 4 inline int max( int a,int b ) 5 { 6 return a > b ? a : b; 7 } 8 void zo( int v,int w ) 9 {10 for( int j = sum; j >= v; --j ) 阅读全文
posted @ 2011-07-25 20:06 贺佐安 阅读(397) 评论(0) 推荐(0) 编辑
摘要: Big Event in HDUTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8035 Accepted Submission(s): 2697Problem DescriptionNowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College 阅读全文
posted @ 2011-07-25 19:56 贺佐安 阅读(565) 评论(0) 推荐(0) 编辑
摘要: Watch The MovieTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1459 Accepted Submission(s): 485Problem DescriptionNew semester is coming, and DuoDuo has to go to school tomorrow. She decides to have fun tonight and will be very busy after tonight. 阅读全文
posted @ 2011-07-25 18:16 贺佐安 阅读(839) 评论(0) 推荐(0) 编辑
摘要: RobberiesTime Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 6 Accepted Submission(s) : 2Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionThe aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guy 阅读全文
posted @ 2011-07-25 16:50 贺佐安 阅读(1261) 评论(1) 推荐(1) 编辑
摘要: Piggy-BankTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2659 Accepted Submission(s): 1314Problem DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes 阅读全文
posted @ 2011-07-25 15:15 贺佐安 阅读(324) 评论(0) 推荐(0) 编辑
摘要: Ahui Writes WordTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 434 Accepted Submission(s): 182Problem DescriptionWe all know that English is very important, so Ahui strive for this in order to learn more English words. To know that word has its . 阅读全文
posted @ 2011-07-25 14:34 贺佐安 阅读(656) 评论(0) 推荐(0) 编辑
摘要: P01: 01背包问题题目有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。基本思路这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是:f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}这个方程非常重要,基本上所有跟背包相关的问题的方程都是由它衍生出来的。所以有必要将它详细解释一下:“将前i件物品放入容量为v的背包中”这个子问题,若只考虑第i件物品的策略(放或不放),那 阅读全文
posted @ 2011-07-25 13:34 贺佐安 阅读(5796) 评论(0) 推荐(0) 编辑
摘要: P01: 01背包问题 题目 有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。 基本思路 这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。 用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值。则其状态转移方程便是:f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}。这个方程非常重要,基本上所有跟背包相关的问题的方程都是由它衍生出来的。所以有必要将它详细解释一下:“将前i件物品放入容量为v的背包中”这个 阅读全文
posted @ 2011-07-25 13:11 贺佐安 阅读(152913) 评论(14) 推荐(47) 编辑
摘要: #include<stdio.h>#include<string.h>intnvalue,m;intprice[110],weigt[110],num[110],fine[110]={0};intmain(){intcas;scanf("%d",&cas);while(cas--){memset(fine,0,sizeof(fine));scanf("%d%d",&nvalue,&m);for(inti=0;i<m;++i)scanf("%d%d%d",price+i,weigt+ 阅读全文
posted @ 2011-07-25 12:14 贺佐安 阅读(512) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#definemax1010structbone{intve,value;}num[max];intT,N,V,Mv[max];intcmp(inta,intb){returna>b?a:b;}intmain(){scanf("%d",&T);while(T--){scanf("%d%d",&N,&V);for(inti=1;i<=N;i++)scanf("%d&quo 阅读全文
posted @ 2011-07-25 12:13 贺佐安 阅读(196) 评论(0) 推荐(0) 编辑