The cost of taking a taxi in Hangzhou is not a constant for each kilometer you travel: the first 4 kilometers costs 10 yuan (yuan is the monetary unit in China), even if you don't finish it; the next 4 kilometers costs 2 yuan each and the price for the rest of the trip is 2.4 yuan per kilometer; the last part of the trip is regarded as 1 kilometer even if it's shorter. A traveller may reduce the cost by reseting the meter at the middle of the trip if used wisely. For example, if the trip is 16 kilometers, he should cut it into two parts with the same length, each half will cost 18 yuan, with an overall cost of 36, less than the original price of 37.2. Now, given the length of the trip, find the minimum cost.

输入

The input contains several cases, each has one positive integer in a seperate line, representing the length of the trip. All input data are less than 10000000. Proceed until a case with zero, which should be ignored.

输出

For each case, output the minimum cost, leave one digit after decimal point if NECESSARY.

样例输入

  1. 3
  2. 9
  3. 16
  4. 0

样例输出

  1. 10
  2. 20.4
  3. 36
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<string.h>
  4. int main()
  5. {
  6. //freopen("input.txt","r",stdin)
  7. double ans;int f;
  8. while(~scanf("%d",&f)&&f)
  9. {
  10. ans=;
  11. if(f>&&f<)ans=;
  12. else if(f>=&&f<=)ans=+*f;
  13. else
  14. {
  15. int k=f%;
  16. ans=*(f-k)/;
  17. if(k<)
  18. ans+=k*2.4;
  19. else
  20. ans+=+(k-)*;
  21. }
  22. printf("%g\n",ans);
  23. }
  24. return ;
  25. }

Mincost的更多相关文章

  1. HD1599 find the mincost route(floyd + 最小环)

    题目链接 题意:求最小环 第一反应时floyd判断,但是涉及到最少3个点,然后就不会了,又想的是 双联通分量,这个不知道为什么不对. Floyd 判断 最小环 #include <iostrea ...

  2. hdoj 1599 find the mincost route【floyd+最小环】

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  3. find the mincost route(最小环,最短路,floyd)

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  4. [hdu P1599] find the mincost route

    [hdu P1599] find the mincost route 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V ...

  5. Multi-target tracking by Lagrangian relaxation to min-cost network flow

    Multi-target tracking by Lagrangian relaxation to min-cost network flow high-order constraints min-c ...

  6. ZOJ2256 Mincost 2017-04-16 19:36 44人阅读 评论(0) 收藏

    Mincost Time Limit: 2 Seconds      Memory Limit: 65536 KB The cost of taking a taxi in Hangzhou is n ...

  7. HDU 1599 find the mincost route(floyd求最小环 无向图)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1599 find the mincost route Time Limit: 1000/2000 MS ...

  8. hdu 1599 find the mincost route (最小环与floyd算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1599 find the mincost route Time Limit: 1000/2000 MS ...

  9. hdu1599 find the mincost route floyd求出最小权值的环

    find the mincost route Time Limit: 1000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  10. 【HDU 1599】 Find the mincost route

    [题目链接] 点击打开链接 [算法] 弗洛伊德求最小环模板 我们知道,在一个环上,一定有一个有且仅有一个编号最大的点,设这个点为k,起点为i,终点为j,那么 mincost = dist[i][j] ...

随机推荐

  1. 【bzoj4939】【YNOI2016】掉进兔子洞(莫队)

    题目描述 您正在打galgame,然后突然发现您今天太颓了,于是想写个数据结构题练练手: 一个长为 n 的序列 a. 有 m 个询问,每次询问三个区间,把三个区间中同时出现的数一个一个删掉,问最后三个 ...

  2. 10.17(山东多校联合模拟赛 day1)

    山东多校联合模拟赛 day1 题不难 rect [问题描述] 给出圆周上的 N 个点, 请你计算出以这些点中的任意四个为四个角,能构成多少个矩形. 点的坐标是这样描述的, 给定一个数组 v[1..N] ...

  3. Django 10 GET和POST(HttpRequest对象,GET和POST请求,文件上传,HttpResponse对象的cookie)

    Django 10 GET和POST(HttpRequest对象,GET和POST请求,文件上传,HttpResponse对象的cookie) 一.HttpRequest对象 #HttpRequest ...

  4. Django 解答 01 (pycharm创建项目)

    pycharm创建项目 1. 2. 3.Tools --->Deployment--->Options 这一条由always 改为 On explicit save action(Ctrl ...

  5. 2015苏州大学ACM-ICPC集训队选拔赛(1) 1007

    连通图 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submissio ...

  6. Hash Join是Oracle CBO时代经常出现的一种连接方式

    Hash Join是Oracle CBO时代经常出现的一种连接方式,对海量数据处理时经常出现在执行计划里.本篇的上篇(http://space.itpub.net/17203031/viewspace ...

  7. Java实现范围内随机数

    JDK1.7及以上 int randomNum = ThreadLocalRandom.current().nextInt(min, max + 1); // 包含max,所以要加1 JDK1.7以前 ...

  8. UDP通讯模型简单示例

    1. UDP通讯模型 2. 服务器端 ① 创建一个socket,用函数socket() ② 绑定IP地址.端口等信息到socket上,用函数bind() ③ 循环接收数据,用函数recvfrom() ...

  9. SecureCRT 遇到一个致命的错误且必须关闭

    1.将报错路径中VanDyke文件夹内的东西删除掉2.运行regedit,在注册表中将HKEY_LOCAL_MACHINA中SOFTWARE里的VanDyke删除3.注册表中打开HKEY_CURREN ...

  10. 8php字符串的方法

    <?php/** * Created by PhpStorm. * User: DY040 * Date: 2017/9/8 * Time: 16:46 *//*php也有转义字符/*///ec ...