Candy Store
Time Limit: 30000ms, Special Time Limit:75000ms, Memory Limit:65536KB
Total submit users: 6, Accepted users: 6
Problem 12624 : No special judgement
Problem description
You are walking with a friend, when you pass a candy store. You make a comment about how unhealthy their wares are. Your friend issues an interesting challenge: who can be the unhealthiest? Both of you will go into the store with the same amount of money. Whoever buys candy with the most total calories wins!

Since you're a smart computer scientist, and since you have access to the candy store's inventory, you decide not to take any chances. You will write a program to determine the most calories you can buy. The inventory tells you the price and calories of every item. It also tells you that there is so much in stock that you can buy as much of any kind of candy as you want. You can only buy whole pieces of candy.

Input
There will be multiple test cases in the input. Each test case will begin with a line with an integer n (1 ≤ n ≤ 5,000), and an amount of money m ($0.01 ≤ m ≤ $100.00), separated by a single space, where n is the number of different types of candy for sale, and m is the amount of money you have to spend. The monetary amount m will be expressed in dollars with exactly two decimal places, and with no leading zeros unless the amount is less than one dollar. There will be no dollar sign. Each of the next nlines will have an integer c (1 ≤ c ≤ 5,000) and an amount of money p ($0.01 ≤ p ≤ $100.00), separated by a single space, where c is the number of calories in a single piece of candy, and p is the price of a single piece of candy, in dollars and in the same format as m. The input will end with a line containing '0 0.00'.

Output
For each test case, output a single integer, indicating the maximum amount of calories you can buy with up to m dollars. Output no spaces, and do not separate answers with blank lines.

Sample Input
2 8.00
700 7.00
199 2.00
3 8.00
700 7.00
299 3.00
499 5.00
0 0.00
Sample Output
796
798
Problem Source

ACM ICPC Southeast USA Regional Programming Contest 2012

完全背包。注意浮点数转化成整数时的精度!用floor转化一下~

 #include <cstdio>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 using namespace std;
 ], C[];
 ];
 ];
 ;
 int main(void)
 {
 //  freopen("in.txt", "r", stdin);
   int n;
   double m;
   while (~scanf("%d%lf", &n, &m)) {
       if (n+m<eps) break;
     ; i < n; ++i) scanf();
     memset(f, , sizeof(f));
     );
     ; i< n; ++i)
       for (int v = C[i]; v <= S; ++v)
         if (f[v] < f[v-C[i] ] + w[i]) f[v] = f[v-C[i] ] + w[i];
     printf("%lld\n", f[S]);
   }
   ;
 }

嗨,中村。

Candy Store的更多相关文章

  1. Web - 客户端存储的几种方式

    客户端存储主要方便一些APP离线使用.今天就来说说客户端存储的方法有多少? 说在最前面的一句:所有的客户端存储都有一个原则:读写的数据必须要同域 1 Cookie Cookie是一项很老的技术的,就是 ...

  2. Distributed PostgreSQL on a Google Spanner Architecture – Storage Layer

    转自:https://blog.yugabyte.com/distributed-postgresql-on-a-google-spanner-architecture-storage-layer/ ...

  3. 深度学习之加载VGG19模型分类识别

    主要参考博客: https://blog.csdn.net/u011046017/article/details/80672597#%E8%AE%AD%E7%BB%83%E4%BB%A3%E7%A0% ...

  4. ImageNet2017文件下载

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

  5. ImageNet2017文件介绍及使用

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

  6. Candy (candy)

    Description Due to its great contribution to the maintenance of world peace, Dzx was given an unlimi ...

  7. iOS之App Store上架被拒Legal - 5.1.5问题

    今天在看到App Store 上架过程中,苹果公司反馈的拒绝原因发现了这么一个问题: Legal - 5.1.5 Your app uses background location services ...

  8. 发布APP到app store

    好久好久没写博客了,主要是 都在学习新东西,忙不赢啊. 近段时间在用AC平台学习开发移动APP, 今天开始发布应用. 在ac云控制台编译成ipa后,使用apple提供的Application Load ...

  9. External Configuration Store Pattern 外部配置存储模式

    Move configuration information out of the application deployment package to a centralized location. ...

随机推荐

  1. JQuery_简单选择器

    jQuery 最核心的组成部分就是:选择器引擎.它继承了 CSS 的语法,可以对 DOM 元素的标签名.属性名.状态等进行快速准确的选择,并且不必担心浏览器的兼容性. jQuery选择器实现了 CSS ...

  2. linux -- 基于mysql tomcat 部署web项目

    一.导入数据库 二.配置web项目访问端口 vim /var/lib/tomcat8/conf/server.xml <Connector port=" protocol=" ...

  3. Java之美[从菜鸟到高手演变]之设计模式

    设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...

  4. jersey处理支付宝异步回调通知的问题:java.lang.IllegalArgumentException: Error parsing media type 'application/x-www-form-urlencoded; text/html; charset=UTF-8'

    tcpflow以流为单位分析请求内容,非常适合服务器端接口类服务查问题 这次遇到的问题跟支付宝支付后的回调post结果有关 淘宝的代码例子: public void doPost(HttpServle ...

  5. F2工作流引擎模型

    工作流引擎(Workflow Engine ) [编辑] 工作流引擎概述 工作流引擎是指workflow(工作流)作为应用系统的一部分,并为之提供对各应用系统有决定作用的根据角色.分工和条件的不同决定 ...

  6. 把DataTable中的数据拼接成XML时遇到的问题

    错误信息:System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Serve ...

  7. MVC、ORM、CURD、ActiveRecord、单一入口的概念

    MVC MVC是一个设计模式,它强制性的使应用程序的输入.处理和输出分开.使用MVC应用程序被分成三个核心部件:模型(M).视图(V).控制器(C),它们各自处理自己的任务. 视图 :视图是用户看到并 ...

  8. 关于ImageLoader的详细介绍

    转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/26810303),请尊重他人的辛勤劳动成果,谢谢! 相信大家 ...

  9. php max_input_vars限制数组大小

    今天做一个项目需要post2000个数组过去,发现一直只能接到一半,后来发现是max_input_vars显示问题. 修改php.ini里面max_input_vars的大小就可以了

  10. GIT(分布式版本控制系统)

    Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目.[1] Git的读音为/gɪt/. Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本 ...