poj 2063 Investment
来源:互联网 发布:端口回流和h323穿透 编辑:程序博客网 时间:2024/06/11 14:04
完全背包的变形操作
#include<iostream>#include<string.h>#include<math.h>#include<fstream>#include<algorithm>#include<stdio.h>#include<queue>#include<vector> #define MAXSIZE 100using namespace std;int N = 0, original = 0, years = 0;int value[11], interest[11], d = 0; int dp[200010];int ans = 0;int main(){ //freopen("data_2063.txt","r",stdin); scanf("%d", &N); while(N--) { ans = 0; memset(dp, 0, sizeof(dp)); scanf("%d%d", &original, &years); scanf("%d", &d); for (int i = 0; i < d; i++) { scanf("%d%d", &value[i], &interest[i]); value[i] /= 1000; } ans = original; for (int i = 0; i < years; i++) { memset(dp, 0, sizeof(dp)); original = ans / 1000; for (int j = 0; j < d; j++) { for (int k = 0; k <= original; k++) { if (k >= value[j]) { dp[k] = max (dp[k], dp[k - value[j]] + interest[j]); } } } ans += dp[original]; } printf("%d\n", ans); } return 0;}
0 0
- poj 2063 Investment
- POJ 2063 Investment
- poj 2063 Investment
- POJ 2063 Investment
- POJ 2063 Investment
- poj 2063 Investment
- Poj 2063 Investment
- poj 2063Investment
- POJ 2063 Investment
- POJ 2063 Investment
- poj 2063 Investment
- poj 2063 Investment
- POJ 2063 Investment
- POJ 2063 Investment
- poj 2063 Investment
- Poj 2063 Investment
- POJ--2063--Investment--背包
- poj 2063 Investment 背包
- poj 2287 Tian Ji -- The Horse Racing
- IOS UITextView 提交建议反馈
- JSTL整理总结
- 躧搿螞 解题报告
- mysql安装后无法登陆或者jdbc无法连接解决方法
- poj 2063 Investment
- 今天是头一天,以后有什么好的资料,就收集到博客里面了。
- 欢迎使用CSDN-markdown编辑器
- 创建对象和使用对象
- 使用common-fileupload实现文件的上传
- 蓝桥杯——二的次幂表示
- java socket tcp重连等 处理粘包、沾包
- 耳塞与听力保护
- halcon边缘提取和赃物检测的常用方法