2012年7月26日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4310解题报告正解是状压dp,当时做反正就贪心贪过去了。。。运气真好。。。View Code #include <iostream>#include <algorithm>using namespace std ;typedef struct L{ int dps,hp ; double ab ;}L ;L kk[1001] ;bool cmp(L a,L b){ return a.ab>b.ab ;}int main(){ int n ; while(~scanf(" 阅读全文
posted @ 2012-07-26 18:14 LegendaryAC 阅读(168) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1849Nim博弈View Code #include <iostream>using namespace std ;int main(){ int n ; while(scanf("%d",&n),n) { int a ; int ans=0 ; while(n--) { scanf("%d",&a) ; ans^=a ; } if(!ans) ... 阅读全文
posted @ 2012-07-26 14:29 LegendaryAC 阅读(159) 评论(0) 推荐(0) 编辑
 
摘要: View Code void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c]+w) ; return ;}void CompletePack(int c,int w){ for(int i=c;i<=V;i++) dp[i]=max(dp[i],dp[i-c]+w) ; return ;}void MultiplePack(int c,int w,int a){ if(c*a>=V) { CompletePack(c,w)... 阅读全文
posted @ 2012-07-26 11:06 LegendaryAC 阅读(128) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2191裸多重背包View Code #include <iostream>#include <algorithm>using namespace std ;int dp[10001] ;int c[101],w[101],num[101] ;int V ;bool cmp(int a,int b){ return a>b ;}void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c 阅读全文
posted @ 2012-07-26 11:05 LegendaryAC 阅读(232) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1171多重背包,学自背包九讲。re一次,dp数组开多大算起来太纠结,尽可能开大就不会有事了wa一次,dp数组没有memset。。。View Code #include <iostream>using namespace std ;int dp[1000001] ;int v[51],num[101] ;int V ;void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c]+w) ; ret... 阅读全文
posted @ 2012-07-26 10:44 LegendaryAC 阅读(141) 评论(0) 推荐(0) 编辑