time limit per test:

1 second

memory limit per test:

256 megabytes

input:

standard input

output:

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.

Input

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 HDC and N (1 ≤ H ≤ 105, 1 ≤ D, C, N ≤ 102).

Output

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 .

Examples
input
   
output
25200.0000
input
   
output
1365.0000
Note

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的更多相关文章

  1. 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 ...

  2. 爬虫requests模块 2

    会话对象¶ 会话对象让你能够跨请求保持某些参数.它也会在同一个 Session 实例发出的所有请求之间保持 cookie, 期间使用 urllib3 的 connection pooling 功能.所 ...

  3. 瘋耔java语言笔记

    一◐ java概述                                                                                        1.1 ...

  4. 建设商城网站ecshop如何开启伪静态

    ecshop是国内一款比较流行的商城网站建设系统,它拥有比较完善的电子商务交易流程,其使用PHP+网站建设者的喜爱.   商城网站也需要网站优化,开启伪静态是个比较好的方法.   ECSHOP的伪静态 ...

  5. 转:Python requests 快速入门

    迫不及待了吗?本页内容为如何入门Requests提供了很好的指引.其假设你已经安装了Requests.如果还没有, 去 安装 一节看看吧. 首先,确认一下: ·Requests 已安装 ·Reques ...

  6. 【PHP开源产品】Ecshop的商品筛选功能实现分析之一

    一.首先,说明一下为什么要对category.php文件进行分析. 原因如下: ①个人对商城类商品筛选功能的实现比较好奇: ②对商城中关于商品的数据表设计比较感兴趣.(该功能涉及到与数据库的交互,而且 ...

  7. Objective-C中的封装、继承、多态、分类

    封装的好处: 过滤不合理的值 屏蔽内部的赋值过程 让外界不必关注内部的细节 继承的好处: 不改变原来模型的基础上,拓充方法 建立了类与类之间的联系 抽取了公共代码 坏处:耦合性强(当去掉一个父类,子类 ...

  8. Python Requests模块讲解4

    高级用法 会话对象 请求与响应对象 Prepared Requests SSL证书验证 响应体内容工作流 保持活动状态(持久连接) 流式上传 块编码请求 POST Multiple Multipart ...

  9. 【nginx运维基础(7)】常用PHP开源程序的NginxRewrite示例

    在写伪静态的时候,可以先用一个打印$_GET的PHP文件来测试,并且一定注意浏览器缓存,另外正则里如果有"{}",正则要用双引号包起来 dedecms location / { r ...

随机推荐

  1. 【HDU 6162】 Ch’s gift

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6162 [算法] 离线树剖 我们知道,u到v路径上权值为[A,B]的数的和 = u到v路径上权值小于 ...

  2. C++_homework_EraseComment

    顾名思义就是删除程序中的注释,不清楚fsm的机制,完全是自己的思路做. 开头先读取一个字符确定是否到文件结尾,如果读取成功,是换行的话就换行,并继续读取,不是的话,用putback放回缓冲区,并整行读 ...

  3. 如何检查ASTGO是限制并发的体验版呢?

    由于网上曾经流传过一段时间来自ASTGO官方的ASTGO体验版(下载地址:http://www.51voip.org/post/33.html),这个版本有个特色就是安装后不需要激活码激活即可打通电话 ...

  4. pull的时候报错

  5. Highways(prim)

    http://poj.org/problem?id=2485 此题是求最小生成树里的最大权值.prim算法: #include<stdio.h> #include<string.h& ...

  6. 0505 php-数组、控制语句、函数

    数 组 (定义.使用.赋值.遍历.分类.冒泡排序) 1.数组包括元素.下标.数组长度 2.php中的数组长度用$len = count("$数组名"); 3.定义一个数组:$arr ...

  7. 使用 Polyfill 而不再是 bable 来实践js新特性

    现状 我们想要用ES6 语法来写 JavaScript.然而由于我们需要兼容老版本的浏览器,那些浏览器不支持 ES6,我们需要解决这个问题. 有一个标准的做法是:写 ES6 代码 → 将所有代码编译成 ...

  8. 基于NPOI的扩展

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.HSS ...

  9. Java 开源博客 Solo 1.2.0 发布 - 一键启动

    Solo 1.2.0 正式发布了,感谢一直以来关注 B3log 开源的朋友! 在这个版本中,我们引入了一个新的特性 -- 独立模式: 不需要安装数据库.Servlet 容器 只需要安装好 Java 环 ...

  10. 水仙花数------"水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。(for循环的嵌套)

    package com.zuoye.test;//打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,//其各位数字立方和等于该数本身.//例如: ...