1031: Mincost
来源:互联网 发布:ubuntu部署openstack 编辑:程序博客网 时间:2024/06/05 20:20
题目描述
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>int main(){ long n,m,k; while(scanf("%ld",&n)!=EOF && n!=0) { k=n%8; m=n/8; if(n<=8) if(n<=4) printf("10\n"); else printf("%ld\n",2*n+2); else if(k<5) if((2*n-m)%5==0) printf("%ld\n",(n/4)*9); else printf("%.1f\n",(float)n*2.4-1.2*(float)m); else printf("%ld\n",2*m+2*n+2); } return 0;}
- 1031: Mincost
- Mincost
- Mincost
- ZOJ2256 Mincost
- ZOJ2256-Mincost
- ZOJ 2256 Mincost
- find the mincost route
- find the mincost route
- zoj 2256 Mincost
- hdu1599find the mincost route
- OJ 21之Mincost(
- find the mincost route
- find the mincost route
- find the mincost route
- find the mincost route
- ZOJ 2256Mincost
- find the mincost rout
- find the mincost route
- MyEclipse Servers视窗出现“Could not create the view: An unexpected exception was thrown”错误解决办法
- php常见的sql语句
- 润乾集算报表通过API修改单元格属性
- 一个读取INI配置文件的类
- Hbase概述
- 1031: Mincost
- vmscan.c
- 属于自己的《程序员的自我修养》之编译和链接
- sap-mm模块核心表清单
- Web简易学生学生管理系统V_2.0
- spring之autowired
- 房贷杠杆降温:水龙头被捏紧多家银行观望情绪浓
- 【Java每日一题】201612015
- acm斐波拉契数列