背包
WePlayDirty
emmmmmmm
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
多重背包的两种解决方法(poj1276)
多重背包是指装入背包的若干见物品种,可以拿的数量有上限。第一种就是二进制优化,转换成01背包,例如一件物品可以拿26件,每一件的权值是w,26可以写成(1+2+4+8)+11,所以就把这种物品分解成权重为w,2w,4w,8w,11w的五种物品,这五种物品组合,一定能组成小于等于26的任意一个数,这样就把有26件的一种物品换成了五种各有一件的物品,用01背包就能解决了。poj原创 2016-08-09 19:51:18 · 2702 阅读 · 0 评论 -
背包 dp
#include#include#includeusing namespace std;int dp[100002];int main(){ int n; while(cin>>n,n!=0) { int a[1200]; memset(dp,0,sizeof(dp)); i原创 2015-01-23 12:33:51 · 2521 阅读 · 0 评论 -
多重背包问题
DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbl原创 2015-01-25 16:30:31 · 2356 阅读 · 0 评论
分享