andre_joy

导航

2012年9月19日

poj 2184

摘要: 地址:http://poj.org/problem?id=2184题意:有很多羊,每只羊有一个幽默度和智商,要选出一些羊,智商加幽默度总和最大,其中智商总和和幽默度总和都不能是负数。mark:变种的01背包,可以把幽默度看成体积,智商看成价值,那么就转换成求体积和价值都为正值的最大值的01背包了。 由于有负数,所以可以每个体积+1000,然后开一个数组记录用该体积得到最大值时用了多少个1000.代码:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#incl 阅读全文

posted @ 2012-09-19 18:39 andre_joy 阅读(1235) 评论(0) 推荐(1) 编辑

hdu 2955

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2955题意:抢银行,给出每一个银行的钱和被抓的概率,被抓的总概率低于p才能顺利逃脱,求最多偷多少钱。mark:01背包的转换,需要把偷的钱当作w来考虑。代码:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream>#include <algorithm>#include <map>#define LL 阅读全文

posted @ 2012-09-19 15:04 andre_joy 阅读(125) 评论(0) 推荐(0) 编辑

UVa 624

摘要: 地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=565题意:背包问题,最多装多少。mark:本题要求输出装的每一个价值,需要回溯一下,必须用二维的。代码:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream>#include <algori 阅读全文

posted @ 2012-09-19 11:42 andre_joy 阅读(149) 评论(0) 推荐(0) 编辑