ZOJ 2224 Investment
来源:互联网 发布:春运迁徙大数据图 编辑:程序博客网 时间:2024/05/22 11:55
完全背包的做法,因为总量都是可以整除1000的 所以直接把重量和开始金钱整除1000,进行完全背包DP,用临时变量保存一不除1000的总值.
#include <iostream>#include <cstdio>#include <memory.h>using namespace std;const int maxn = 11;int cap, years, n;int w[maxn], v[maxn], dp[60000];int main(){int T;scanf("%d", &T);while(T--){scanf("%d %d %d", &cap, &years, &n);int ans = cap;for(int i = 0; i < n; ++i){scanf("%d %d", &w[i], &v[i]);w[i] /= 1000;}for(int i = 0; i < years; ++i){cap /= 1000;memset(dp, 0, sizeof(dp));for(int j = 0; j < n; ++j){for(int k = w[j]; k <= cap; ++k){dp[k] = max(dp[k], dp[k - w[j]] + v[j]);}}ans += dp[cap];cap = ans;}printf("%d\n", ans);}return 0;}
- ZOJ 2224 Investment
- zoj 2224 - Investment
- poj 2063& zoj 2224 Investment
- 2224Investment——zoj
- poj 2063 Investment ( zoj 2224 Investment ) 完全背包
- ZOJ 2224 Investment (完全背包)
- zoj 2224 || poj 2063 Investment(完全背包!)
- poj 2063& zoj 2224 Investment (多次完全背包)
- Investment
- dmabounce investment
- poj2063 - Investment
- poj2063 Investment
- POJ2063--Investment
- POJ2063 Investment
- Business investment
- POJ2063 Investment
- POJ2063 Investment
- poj2063 Investment
- 是否应该使用ARC?
- 在次线程中下载,在主线程更新的例子
- Java代理技术
- WIN7可中SQL SERVER 2008安装时出现不能在控件上调用 Invoke 或 BeginInvoke错误(终极解决方法)
- C++ 队列 实现 多项式 加减法
- ZOJ 2224 Investment
- Shell脚本调试技术
- Java 入门 三 (Java三大特性 之一 封装 )
- Fedora下自动挂载Windows分区的方法及权限问题
- nbu 2412 Dice
- FileStream 和 StreamWriter/StreamReader
- Cuda的一些配置
- 向PDF文件插入图片
- 虚函数和纯虚函数的区别