Candy Store
| 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的更多相关文章
- Web - 客户端存储的几种方式
客户端存储主要方便一些APP离线使用.今天就来说说客户端存储的方法有多少? 说在最前面的一句:所有的客户端存储都有一个原则:读写的数据必须要同域 1 Cookie Cookie是一项很老的技术的,就是 ...
- Distributed PostgreSQL on a Google Spanner Architecture – Storage Layer
转自:https://blog.yugabyte.com/distributed-postgresql-on-a-google-spanner-architecture-storage-layer/ ...
- 深度学习之加载VGG19模型分类识别
主要参考博客: https://blog.csdn.net/u011046017/article/details/80672597#%E8%AE%AD%E7%BB%83%E4%BB%A3%E7%A0% ...
- ImageNet2017文件下载
ImageNet2017文件下载 文件说明 imagenet_object_localization.tar.gz包含训练集和验证集的图像数据和地面实况,以及测试集的图像数据. 图像注释以PASCAL ...
- ImageNet2017文件介绍及使用
ImageNet2017文件介绍及使用 文件说明 imagenet_object_localization.tar.gz包含训练集和验证集的图像数据和地面实况,以及测试集的图像数据. 图像注释以PAS ...
- Candy (candy)
Description Due to its great contribution to the maintenance of world peace, Dzx was given an unlimi ...
- iOS之App Store上架被拒Legal - 5.1.5问题
今天在看到App Store 上架过程中,苹果公司反馈的拒绝原因发现了这么一个问题: Legal - 5.1.5 Your app uses background location services ...
- 发布APP到app store
好久好久没写博客了,主要是 都在学习新东西,忙不赢啊. 近段时间在用AC平台学习开发移动APP, 今天开始发布应用. 在ac云控制台编译成ipa后,使用apple提供的Application Load ...
- External Configuration Store Pattern 外部配置存储模式
Move configuration information out of the application deployment package to a centralized location. ...
随机推荐
- BZOJ 2600: [Ioi2011]ricehub
2600: [Ioi2011]ricehub Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 628 Solved: 325[Submit][Stat ...
- <hr/> 水平线样式
<hr style="width:490px;" /> <hr size=8 style="COLOR: #ffd306;border-style:ou ...
- 轻松解决Linux安装Eclipse方法
随着Linux的发展,很多人开始学习Linux系统,你了解Linux系统么?你是Linux系统的应用者么?本文为你详细介绍Linux安装Eclipse,为你在学习Linux安装Eclipse时起一定的 ...
- Scrum Meeting 4-20151204
任务安排 姓名 今日任务 明日任务 困难 董元财 学习上拉加入新的listview 无 胡亚坤 设计优化聊天页面 无 刘猛 请假(参加编译测试,提前准备) 无 马汉虎 请假(参加编译测试,提前准备) ...
- WebSocket实战之————GatewayWorker使用笔记例子
参考文档:http://www.workerman.net/gatewaydoc/ 目录结构 ├── Applications // 这里是所有开发者应用项目 │ └── YourApp // 其中一 ...
- sqlAlchemy 按DateTime字段的年或月进行group_by查询
一.根据”create_date“查询每天的数据 1.查询2016年5月每天的数据 session.query(extract('day', User.create_date).label('day' ...
- iOS开发 Masonry的简单使用
首先,在正式使用Masonry之前,我们先来看看在xib中我们是如何使用AutoLayout 从图中我们可以看出,只要设置相应得局限,控制好父视图与子视图之间的关系就应该很ok的拖出你需要的需 ...
- php支付宝在线支付接口开发教程【转】
php支付宝在线支付接口开发教程 这篇文章主要为大家详细介绍了php支付宝在线支付接口开发教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 1.什么是第三方支付 所谓第三方支付,就是一些和各 ...
- SPSS数据分析—简单线性回归
和相关分析一样,回归分析也可以描述两个变量间的关系,但二者也有所区别,相关分析可以通过相关系数大小描述变量间的紧密程度,而回归分析更进一步,不仅可以描述变量间的紧密程度,还可以定量的描述当一个变量变化 ...
- js javascript 模拟点击 超级链接点击 转
转自:http://mo2g.com/view/42/ 我尝试过多次用jQuery模拟用户点击a标签的功能,但都没有成功,并且困扰了很久.前段时间的一次发呆,冒出了新的想法,于是就动手进行了测试. 先 ...