ZOJ 2256Mincost
来源:互联网 发布:淘宝客网站推广技巧 编辑:程序博客网 时间:2024/06/05 14:22
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<bits/stdc++.h>using namespace std;const int N=1e5+10;int n;double f[N];int main(){ f[0]=f[1]=f[2]=f[3]=f[4]=10; f[5]=12; f[6]=14; f[7]=16; f[8]=18; while(~scanf("%d",&n)&&n) { if (n<=8) printf("%d\n",(int)f[n]); else { if (n%8==0) printf("%d\n",(int)(n/8*f[8])); else { double k=(n/8)*f[8]; if (n%8<5) printf("%.1lf\n",k+(n%8)*2.4); else printf("%d\n",(int)(k+f[n%8])); } } } return 0;}
- ZOJ 2256 Mincost
- zoj 2256 Mincost
- ZOJ 2256Mincost
- Mincost
- Mincost
- 1031: Mincost
- ZOJ2256 Mincost
- ZOJ2256-Mincost
- ZOJ-2256
- find the mincost route
- find the mincost route
- hdu1599find the mincost route
- OJ 21之Mincost(
- find the mincost route
- find the mincost route
- find the mincost route
- find the mincost route
- find the mincost rout
- jdk环境的配置
- 【C语言】常用的转义字符及其含义
- android学习笔记(4)
- 一条sql语句分组、升序、指定条数查询
- Exploring Heap-Based Buffer Overflows with the Application Verifier
- ZOJ 2256Mincost
- 【单例模式】简单C++实现
- 《腾讯传》读后感
- Android Apk的打包流程
- 详谈数据库事务
- GitHub使用步骤
- 百度云干货资源
- 1
- border的那些事——简单的颜色控制边框外观