Hrbust1053 Warcraft III (完全背包)
来源:互联网 发布:windows设置ntp客户端 编辑:程序博客网 时间:2024/05/18 20:09
本文出自:http://blog.csdn.net/svitter
原题:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1053
题意:完全背包不解释。。直接贴代码。。
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;#define max(a, b) a > b? a : bstruct Unit{int val;int cost;};Unit unit[100000];int f[100000];void ace(){//work pointint t;int i, j, k;//numint g, u, n; // n means sizecin >> t;while(t--){memset(f, 0 ,sizeof(f));scanf("%d%d", &g, &u);for(i = 0; i < u; i++){scanf("%d%d", &unit[i].val, &unit[i].cost);}for(i = 0; i < u; i++){n = g - unit[i].cost;for(j = 0; j <= n; j++){f[j + unit[i].cost] = max(f[j +unit[i].cost], f[j] + unit[i].val);}}printf("%d\n", f[g]);}}int main(){ ace();return 0;}
1 0
- Hrbust1053 Warcraft III (完全背包)
- hrbust1053 Warcraft III (完全背包裸题)
- HLG 哈理工 1053 Warcraft III (完全背包)
- Hust oj 1053 Warcraft III(完全背包)
- HLG 1053 Warcraft III 完全背包
- HLG 1053 Warcraft III(背包DP)
- HDU 3008 Warcraft (DP 背包)
- HDU-1028-Ignatius and the Princess III(完全背包)
- HLG Warcraft III
- Warcraft III 分辨率设置
- vijos1067 Warcraft III 守望者的烦恼(矩阵倍增)
- 南邮 OJ 1443 Warcraft III
- LintCode Backpack III(背包III)
- hdu 1028 Ignatius and the Princess III(母函数,完全背包)
- HDU-1028 Ignatius and the Princess III(DP[完全背包]||生成函数)
- HDU--1028--Ignatius and the Princess III--完全背包
- HDU1028 Ignatius and the Princess III【母函数】【完全背包】
- hdu1028 Ignatius and the Princess III (完全背包)
- how to deal with the situation that the language support option disappears in linux ubuntu
- Ubuntu装wifi驱动(三步搞掂)
- 最好用的汉字转拼音代码PinYin4Objc(PinYin4J的objc版本)(更新到v1.1.1,增加block异步处理)┊
- .net micro framework的入门例程-点灯神话-6.使用定时器代替延时函数闪烁LED
- grep 用法详解
- Hrbust1053 Warcraft III (完全背包)
- hdu 4704 Sum(费马小定理)
- mac 下杀死一个端口号对应的进程
- .net micro framework的入门例程-点灯神话-7.队列存储LED灯闪烁时间并用串口发送
- epoll的原理和用法
- PIL模块与随机生成中文验证码
- 程序中使用cocostudio移植到android手机需要的若干配置过程
- 选择重传协议 C语言实现
- 发布或重启线上服务时抖动问题解决方案