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.

样例输入

3
9
16
0

样例输出

10
20.4
36
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
//freopen("input.txt","r",stdin)
double ans;int f;
while(~scanf("%d",&f)&&f)
{
ans=;
if(f>&&f<)ans=;
else if(f>=&&f<=)ans=+*f;
else
{
int k=f%;
ans=*(f-k)/;
if(k<)
ans+=k*2.4;
else
ans+=+(k-)*;
}
printf("%g\n",ans);
}
return ;
}

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. P3613 睡觉困难综合征 LCT+贪心+位运算

    \(\color{#0066ff}{ 题目描述 }\) 由乃这个问题越想越迷糊,已经达到了废寝忘食的地步.结果她发现--晚上睡不着了!只能把自己的一个神经元(我们可以抽象成一个树形结构)拿出来,交给D ...

  2. pycharm加开头注释

    选择 File and Code Templates -> Files -> Python Script #!/usr/bin/env python # encoding: utf-8 ' ...

  3. STS(spring tool suite)修改默认编码

    安装STS后首先要做的修改默认编码: 1.windows--perferences--general--workspace,Text file encoding设置成utf-8 2.windows-- ...

  4. Solr学习笔记(1) —— Solr概述&Solr的安装

    一.概述 使用Solr实现电商网站中商品信息搜索功能,可以根据关键字.分类.价格搜索商品信息,也可以根据价格进行排序. 1.1 实现方法 在一些大型门户网站.电子商务网站等都需要站内搜索功能,使用传统 ...

  5. 网络中常用的各种协议(针对TCP/IP协议组)

    网络层: ip协议->网络互连协议 用途:将多个包在网络中联系起来,传输数据包(不可靠传输),最基本功能就是寻址和分段功能,不提供端到端,路由到路由的确认,不提供重发和流量控制.是计算机网络能狗 ...

  6. Linux软件源apt 仓库 包 的概念

    概念介绍: 软件源是debian系的概念,把软件放在一个pool里面,用一条命令就可以自动从指定服务器下载并安装. 源列表是/etc/apt/sources.list,里面写了你所用的服务器地址 (其 ...

  7. Experimental Educational Round: VolBIT Formulas Blitz B

    Description The city administration of IT City decided to fix up a symbol of scientific and technica ...

  8. Codeforces Round #335 (Div. 2) A

    A. Magic Spheres time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  9. Go语言基础之6--值类型和引用类型

    一. 引用类型 引用类型理解为(C语言):指针 Golang中只有三种引用类型:slice(切片).map(字典).channel(管道): 实例1-1 package main import &qu ...

  10. mc01_IntelliJ IDEA安装与Java项目创建以及Tomcat配置

    IntelliJ IDEA安装与激活 下载地址:http://www.jetbrains.com/idea/ 安装下一步下一步即可,关键是注册激活,该部分分两个步骤: 1. 配置windows hos ...