A. Feed the cat
1 second
256 megabytes
standard input
standard output
After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another time (guess why there's only one cat). The cat's current hunger level is H points, moreover each minute without food increases his hunger by D points.
At any time Andrew can visit the store where tasty buns are sold (you can assume that is doesn't take time to get to the store and back). One such bun costs C roubles and decreases hunger by N points. Since the demand for bakery drops heavily in the evening, there is a special 20% discount for buns starting from 20:00 (note that the cost might become rational). Of course, buns cannot be sold by parts.
Determine the minimum amount of money Andrew has to spend in order to feed his cat. The cat is considered fed if its hunger level is less than or equal to zero.
The first line contains two integers hh and mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59) — the time of Andrew's awakening.
The second line contains four integers H, D, C and N (1 ≤ H ≤ 105, 1 ≤ D, C, N ≤ 102).
Output the minimum amount of money to within three decimal digits. You answer is considered correct, if its absolute or relative error does not exceed 10 - 4.
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .
25200.0000
1365.0000
In the first sample Andrew can visit the store at exactly 20:00. The cat's hunger will be equal to 315, hence it will be necessary to purchase 315 buns. The discount makes the final answer 25200 roubles.
In the second sample it's optimal to visit the store right after he wakes up. Then he'll have to buy 91 bins per 15 roubles each and spend a total of 1365 roubles.
思路:可以证明,如过当前时间不到20:00,那么最优支付方案一定是立刻购买和20:00购买中的一个。如果已经到了20:00,那里可购买就是最优的。
然后模拟就可以了。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int hh,mm,h,d,c,n;
double work1(){
double tmp=h/n+(h%n>?:);tmp*=c;
return tmp;
}
double work2(){
int sum=*-hh*-mm;h+=sum*d;
double tmp=h/n+(h%n>?:);tmp*=c;
tmp*=0.8;
return tmp;
}
int main(){
scanf("%d%d",&hh,&mm);
scanf("%d%d%d%d",&h,&d,&c,&n);
if(hh>=){
double ans=h/n+(h%n>?:);
printf("%.4lf",ans*c*0.8);
return ;
}
double ans1=work1();
double ans2=work2();
printf("%.4lf",min(ans1,ans2));
}
A. Feed the cat的更多相关文章
- Codeforces Round #471 (Div. 2)A. Feed the cat
After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another ...
- 爬虫requests模块 2
会话对象¶ 会话对象让你能够跨请求保持某些参数.它也会在同一个 Session 实例发出的所有请求之间保持 cookie, 期间使用 urllib3 的 connection pooling 功能.所 ...
- 瘋耔java语言笔记
一◐ java概述 1.1 ...
- 建设商城网站ecshop如何开启伪静态
ecshop是国内一款比较流行的商城网站建设系统,它拥有比较完善的电子商务交易流程,其使用PHP+网站建设者的喜爱. 商城网站也需要网站优化,开启伪静态是个比较好的方法. ECSHOP的伪静态 ...
- 转:Python requests 快速入门
迫不及待了吗?本页内容为如何入门Requests提供了很好的指引.其假设你已经安装了Requests.如果还没有, 去 安装 一节看看吧. 首先,确认一下: ·Requests 已安装 ·Reques ...
- 【PHP开源产品】Ecshop的商品筛选功能实现分析之一
一.首先,说明一下为什么要对category.php文件进行分析. 原因如下: ①个人对商城类商品筛选功能的实现比较好奇: ②对商城中关于商品的数据表设计比较感兴趣.(该功能涉及到与数据库的交互,而且 ...
- Objective-C中的封装、继承、多态、分类
封装的好处: 过滤不合理的值 屏蔽内部的赋值过程 让外界不必关注内部的细节 继承的好处: 不改变原来模型的基础上,拓充方法 建立了类与类之间的联系 抽取了公共代码 坏处:耦合性强(当去掉一个父类,子类 ...
- Python Requests模块讲解4
高级用法 会话对象 请求与响应对象 Prepared Requests SSL证书验证 响应体内容工作流 保持活动状态(持久连接) 流式上传 块编码请求 POST Multiple Multipart ...
- 【nginx运维基础(7)】常用PHP开源程序的NginxRewrite示例
在写伪静态的时候,可以先用一个打印$_GET的PHP文件来测试,并且一定注意浏览器缓存,另外正则里如果有"{}",正则要用双引号包起来 dedecms location / { r ...
随机推荐
- KD树——k=1时就是BST,里面的数学原理还是有不明白的地方,为啥方差划分?
Kd-Tree,即K-dimensional tree,是一棵二叉树,树中存储的是一些K维数据.在一个K维数据集合上构建一棵Kd-Tree代表了对该K维数据集合构成的K维空间的一个划分,即树中的每个结 ...
- HDU 6069 Counting Divisors(2017 Multi-University Training Contest - Team 4 )
Output For each test case, print a single line containing an integer, denoting the answer. Sample ...
- hdu 1035(DFS)
Robot Motion Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- B1192 [HNOI2006]超级英雄Hero 二分图匹配
先检讨一下,前一段时间开学,做题懒得发博客,也不总结...现在捡起来. 这个题一看是裸的二分图匹配,但是仔细一看还有一些区别,就是必须要连续的连接,否则直接退出.因为前一道题答不出来的话后面的题就没有 ...
- 79.员工薪水报表 Extjs 页面
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" ...
- 85.Ext.Window
转自:https://chenjumin.iteye.com/blog/668421 1.主要配置项: closable:是否允许关闭窗口,默认为true. closeActi ...
- Necklace of Beads(polya定理)
http://poj.org/problem?id=1286 题意:求用3种颜色给n个珠子涂色的方案数.polya定理模板题. #include <stdio.h> #include &l ...
- Django day13 form组件, 渲染错误信息, 全局钩子
一:from组件 二:渲染错误信息 三:全局钩子
- ASP.NET Core 多环境
ASP.NET Core 支持在多个环境中管理应用程序,如开发(Development),预演(Staging)和生产(Production).环境变量用来指示应用程序正在运行的环境,允许应用程序适当 ...
- BZOJ 1511 KMP
题意:求出每个前缀的最长周期之和(等于本身的算0) 思路: 求出来next数组 建出next树 找到不为0的最小的 n减去它就是答案 //By SiriusRen #include <cstd ...