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 ;
}

最新文章

  1. Ajax 概念 分析 举例
  2. [ASP.NET MVC] 利用自定义的AuthenticationFilter实现Basic认证
  3. 《舌尖上的中国》第二季今日首播了,天猫食品也跟着首发,借力使力[bubuko.com]
  4. neon指令,注意事项
  5. Java调用JavaScript
  6. 3D数学基础:3D游戏动画中欧拉角与万向锁的理解
  7. 【转载】linux命令行计算器bc的一个“坑”
  8. BZOJ3132: 上帝造题的七分钟
  9. [Machine Learning (Andrew NG courses)]IV.Linear Regression with Multiple Variables
  10. javascript call和apply
  11. 修改/etc/resolv.conf又恢复到原来的状态?[转]
  12. js实现的文章输入检查与测速。
  13. Applovin Interview (面经)
  14. gpu相关
  15. [NewLife.XCode]事务处理(算准你的每一分钱)
  16. 利用exif.js解决手机上传竖拍照片旋转90\180\270度问题
  17. numpy 性能提升
  18. cocos creator 动态创建精灵
  19. python中datetime与string的相互转换
  20. sqlcipher 数据库解密

热门文章

  1. linux中脚本权限问题以及win下使用telnet测试linux端口
  2. JS模式和原型精解
  3. vim 常用配置项
  4. 2016&quot;百度之星&quot; - 资格赛(Astar Round1)D
  5. 06-图2 Saving James Bond - Easy Version (25 分)
  6. NETSpider 网络蜘蛛采集工具
  7. java在window系统的一些问题
  8. Alibaba Java Coding Guidelines 安装(eclipse)并简单使用
  9. Linux执行.sh文件Permission denied
  10. C# Linq 查询数据库(DataSet)生成 Tree