link:http://acm.hdu.edu.cn/showproblem.php?pid=1114

只不过求得是最小值。没什么可说的,连我都会做……o(╯□╰)o

 /*
ID: zypz4571
LANG: C++
TASK: pig.cpp
*/ #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
int f[],c[],w[], V, n;
void completepack(int c,int w) {
for(int v=c;v<=V;++v)
f[v]=min(f[v],f[v-c]+w);
}
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
int t; cin>>t;
while (t--) {
int e, F; cin>>e>>F; V=F-e; cin>>n;
for(int i=;i<n;++i) cin>>c[i]>>w[i];
memset(f,INF,sizeof(f)); f[]=;
for (int i=;i<n;++i) completepack(w[i],c[i]);
if(f[V]==INF) cout<<"This is impossible.\n";
else cout<<"The minimum amount of money in the piggy-bank is "<<
f[V]<<".\n";
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */

o(╯□╰)o

hdu1114 Piggy-Bank ——完全背包的更多相关文章

  1. BZOJ 1531: [POI2005]Bank notes( 背包 )

    多重背包... ---------------------------------------------------------------------------- #include<bit ...

  2. hdu1114 dp(完全背包)

    题意:已知空钱罐质量和满钱罐质量(也就是知道钱罐里的钱的质量),知道若干种钱币每种的质量以及其价值,钱币都是无限个,问最少钱罐中有多少钱. 这个题在集训的时候学长给我们做过,所以你会做是应该的,由于已 ...

  3. kuangbin专题十二 HDU1114 Piggy-Bank (完全背包)

    Piggy-Bank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  4. HDU1114 Piggy-Bank 【全然背包】

    Piggy-Bank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  5. HDU1114 Piggy-Bank —— DP 完全背包

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1114 Piggy-Bank Time Limit: 2000/1000 MS (Java/ ...

  6. HDU1114 Piggy-Bank (完全背包)

    完全背包模板,和01背包相比不用倒推,因为一种可以选多个. 这道题求最小,dp数组初始化为无穷即可. 1 #include<iostream> 2 #include<cstring& ...

  7. ACM Piggy Bank

    Problem Description Before ACM can do anything, a budget must be prepared and the necessary financia ...

  8. ImageNet2017文件下载

    ImageNet2017文件下载 文件说明 imagenet_object_localization.tar.gz包含训练集和验证集的图像数据和地面实况,以及测试集的图像数据. 图像注释以PASCAL ...

  9. ImageNet2017文件介绍及使用

    ImageNet2017文件介绍及使用 文件说明 imagenet_object_localization.tar.gz包含训练集和验证集的图像数据和地面实况,以及测试集的图像数据. 图像注释以PAS ...

  10. Android开发训练之第五章第五节——Resolving Cloud Save Conflicts

    Resolving Cloud Save Conflicts IN THIS DOCUMENT Get Notified of Conflicts Handle the Simple Cases De ...

随机推荐

  1. Zabbix页面遇到历史记录的乱码需要修改数据库

    Zabbix页面遇到历史记录的乱码需要修改数据库: 解决办法: 1.将 zabbix 数据库中的表备份: 2.手动删除 zabbix 数据库: 3.重新创建 zabbix 库时手动指定字符集为 utf ...

  2. mongo .update

    db.classes.update({"count":{$gt:20}},{$set:{"name":"c4"}},false,false) ...

  3. vi编辑器选项

    Vi编辑器有一些选项设置可以帮助人们更好的使用. 在vi中选项分为两种: 1.  开关选项,如果要打开这类选项就使用ex命令——:set 选项:如果要关闭这类选项就是用ex命令——:set  no选项 ...

  4. [网络技术]VPN设置

    1.解决VPN服务器默认路由困扰 现在移动办公已经变得家常便饭,每次外出出差办公需要访问单位的内网服务器时,该怎么办呢?相信很多人都想到了VPN连接!的确,使用VPN连接, 我们可以利用现成的Inte ...

  5. SharePoint 2013 配置我的网站 图文引导

    博客地址:http://blog.csdn.net/FoxDave 本篇我们来讲述一下关于SharePoint中我的网站(My Sites)相关的东西. 我的网站是SharePoint 2013中面向 ...

  6. jQuery 自定义扩展,与$冲突处理

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. Javascript ----字符串(String)中的方法

    涉及字符串时,常用到的几个方法... --------------------------------------------------------------------------------- ...

  8. Linux Mint下编译Bochs

    我在Linux Mint命令行下输入sudo apt-get install bochs安装之后发现这个没有安装gui界面,使用也存在一些问题,所以直接删掉从官网下载代码自己编译安装. 给Linux ...

  9. OD调试篇5--如何应对OD使用中的一些问题

    打开小甲鱼给的进行恶搞过的程序,会发现一些问题 发现程序直接暂停,或者加载进来有问题. 那机智的我 通过对上一个没有恶搞过的exe可执行文件的PE头进行了比较 会发现其中的猫腻 那么我们去正常的修改一 ...

  10. ERP员工入职登记(五)

    在数据库中添加链接的地址: