poj2063
来源:互联网 发布:网络利大于弊的问题 编辑:程序博客网 时间:2024/06/11 11:12
#include<iostream>
using namespace std;
int c[15];
int w[15];
int f[45001];
int main()
{
int T,i,j,n,v,V,kind,m,temp;
cin>>T;
while(T-->0)
{
cin>>V>>n;
cin>>kind;
for(i=1;i<=kind;i++)
{
cin>>c[i]>>w[i];
c[i]=c[i]/1000;
}
temp=V;
for(i=1;i<=n;i++)//遍历年份
{
V=temp;
V/=1000;
for(m=0;m<=V;m++)
f[m]=0;
for(j=1;j<=kind;j++)//遍历物品
{
for(v=c[j];v<=V;v++)
f[v]=max(f[v-c[j]]+w[j],f[v]);
}
temp+=f[V];
}
cout<<temp<<endl;
}
system("pause");
return 0;
}
本题目是一个完全背包的变形,很水,只要思路理清就好了。。。
- poj2063
- poj2063
- POJ2063
- poj2063 - Investment
- poj2063 Investment
- POJ2063--Investment
- POJ2063 Investment
- POJ2063 Investment
- POJ2063 Investment
- poj2063 Investment
- poj2063 Investment
- 【POJ2063】【Investment】
- poj2063 Investment
- POJ2063-Investment
- POJ2063 Investment
- poj2063 完全背包
- poj2063(还是背包)Investment
- poj2063 Investment 完全背包
- 硬盘主引导记录(MBR)及其结构
- 看书
- vi命令拾遗
- Asp.net前台调后台方法
- 各种排序源程序(附带驱动程序,直接可以测试)
- poj2063
- TFS API: 获取自定义查询--使用QueryHierarchy
- TCP SOCKET CLOSE_WAIT状态暂时心得
- Android Keyboard/Touch Panel分析
- 无心
- 为什么使用FindFirstVolume的时候,会报“error C2065: 'FindFirstVolume' : undeclared identifier”这个错误呢?????
- 怎样恢复"显示桌面"快速启动按钮
- MongoDB的Java驱动使用整理
- Mainsoft的Grasshopper让你可以使用C#编写Java可以调用的类库(免费了!)