买债券之完全背包
来源:互联网 发布:数控车床编程教学视频 编辑:程序博客网 时间:2024/04/30 00:07
#include <stdio.h>
#define MAX(X,Y) (X)>(Y)?(X):(Y)
struct Bond
{
int cost;
int interest;
};
int nBond;
Bond bonds[11];
int Base;
int dp[45300];
int GetMaximum()
{
int i,j;
for( i = 0; i <= Base; i++)
{
dp[i] = 0;
}
for( i = 0;i < nBond; i++)
{
for( j = bonds[i].cost; j <= Base; j++)
{
dp[j] = MAX(dp[j], dp[j-bonds[i].cost] + bonds[i].interest);
}
}
return dp[Base];
}
int main()
{
int nCase, nYears;
scanf("%d", &nCase);
while(nCase--)
{
scanf("%d%d", &Base, &nYears);
scanf("%d", &nBond);
int sum = Base;
for(int i = 0; i < nBond; i++)
{
scanf("%d%d", &bonds[i].cost, &bonds[i].interest);
bonds[i].cost /= 1000;
}
for(int i = 0;i < nYears; i++)
{
Base = sum / 1000;
sum += GetMaximum();
}
printf("%d\n", sum);
}
return 0;
}
- 买债券之完全背包
- 背包探索之完全背包
- 白话背包之完全背包
- 01背包之完全背包
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解 Acm
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- DP背包之01背包、完全背包、多重背包笔记
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- 背包之01背包、完全背包、多重背包详解
- MySQL数据类型
- ibatis使用存储过程的时候发现了点问题
- opencv图像分割
- UVA 10098 (13.07.18)
- HDU2955
- 买债券之完全背包
- hdu2514 Another Eight Puzzle (全排列、暴力)
- JAVA深层拷贝 - DeepCopy
- UVA 729 (13.07.18)
- jQuery Ajax 方法调用 Asp.Net WebService 的详细例子
- jQuery选择器和方法的等价关系
- Ajax原生态
- HDU汶川512之多重背包
- 苹果山狮系统隐藏的美丽壁纸