hdu 3127 WHUgirls
来源:互联网 发布:淘宝上怎么注册开店 编辑:程序博客网 时间:2024/05/27 09:45
http://acm.hdu.edu.cn/showproblem.php?pid=3127
题意:用规定大小的布裁给出的布,获得最大利润,可以不完全用完布,二维完全背包
分化方案:
#include<iostream>
#include<cstdio>
using namespace std;
int f[1002][1002];
struct CLOTH
{
int x,y,vau;
}cloth[15];
int max(int x,int y)
{
return x>y?x:y;
}
int main()
{
int T,N,X1,Y1,i,j,k;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&N,&X1,&Y1);
for(i=0;i<N;i++)
scanf("%d%d%d",&cloth[i].x,&cloth[i].y,&cloth[i].vau);
memset(f,0,sizeof(f));
for(i=0;i<=X1;i++)
{
for(j=0;j<=Y1;j++)
{
for(k=0;k<N;k++)//放到内层循环
{
if(i>=cloth[k].x&&j>=cloth[k].y)
f[i][j]=max(f[i][j],max(f[i-cloth[k].x][j]+f[cloth[k].x][j-cloth[k].y]+cloth[k].vau,f[i][j-cloth[k].y]+f[i-cloth[k].x][cloth[k].y]+cloth[k].vau));
if(j>=cloth[k].x&&i>=cloth[k].y)
f[i][j]=max(f[i][j],max(f[i-cloth[k].y][j]+f[cloth[k].y][j-cloth[k].x]+cloth[k].vau,f[i][j-cloth[k].x]+f[i-cloth[k].y][cloth[k].x]+cloth[k].vau));
}
}
}
printf("%d\n",f[X1][Y1]);
}
return 0;
}
- hdu 3127 WHUgirls
- hdu 3127 WHUgirls
- HDU 3127 WHUgirls
- HDU 3127 WHUgirls
- hdu 3127 WHUgirls
- 【HDU】 3127 WHUgirls
- HDU-3127 WHUgirls
- HDU 3127 WHUgirls 背包问题
- HDU 3127 WHUgirls (完全背包)
- HDU 3127 WHUgirls(完全背包)
- hdu-3127-WHUgirls解题报告
- HDU 3127 WHUgirls(完全背包)
- HDU OJ 3127 WHUgirls【DP之背包】
- hdu 3127 WHUgirls 二维完全背包
- HDU 3127 WHUgirls dp背包问题
- HDU OJ 3127 WHUgirls【DP之背包】
- hdu——3127——WHUgirls
- 【DP】HDU 3127 WHUgirls 完全背包
- 在文档库中向指定的文件夹添加文档
- 【VC++】FormatMessage 获取 GetLastError 信息。
- 关于分页管理
- CSS详解— —媒体查询(2)
- oracle select any dictionary & oracle授权详解
- hdu 3127 WHUgirls
- 再分享一个自己写的向量和二维坐标变换的类
- objective-c没有类静态成员变量
- PowerDesigner反向工程导出模型图
- (3万错误,No.2),PHP不报错误,并且设置了error_reporting(E_ALL)
- Linux的Netlink机制
- android安卓手机变身无线网卡,实现“畅无线“电脑版”台式机笔记本通杀
- 用1.4.10 Synergy配置Win7(64位)和Ubuntu(64位)
- Android应用程序与SurfaceFlinger服务的关系概述和学习计划