http://acm.hdu.edu.cn/showproblem.php?pid=2191
题意:你所拥有的金额为V,物品种类为n,每种价格为cost,重量为weight,数量有限为amount个,求用这些钱(可剩余)可以买到最多多重的粮食?
思路:每种物品数量有限,多重背包。直接用九讲里二进制优化过的模板就行。每种物品拆分为系数为2次幂的物品,对这些物品用以01背包的思想,背包不要求装满。
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;
typede