Mincost
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的更多相关文章
- HD1599 find the mincost route(floyd + 最小环)
题目链接 题意:求最小环 第一反应时floyd判断,但是涉及到最少3个点,然后就不会了,又想的是 双联通分量,这个不知道为什么不对. Floyd 判断 最小环 #include <iostrea ...
- 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 ...
- find the mincost route(最小环,最短路,floyd)
find the mincost route Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- [hdu P1599] find the mincost route
[hdu P1599] find the mincost route 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- hdu1599 find the mincost route floyd求出最小权值的环
find the mincost route Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- 【HDU 1599】 Find the mincost route
[题目链接] 点击打开链接 [算法] 弗洛伊德求最小环模板 我们知道,在一个环上,一定有一个有且仅有一个编号最大的点,设这个点为k,起点为i,终点为j,那么 mincost = dist[i][j] ...
随机推荐
- Mole and Abandoned Mine
Mole and Abandoned Mine n点m条边的无向图,删除第i条边花费c[i],问1到n只有一条路径时所需要的最小花费? \(2\le n\le 15\) . 我又A掉了一道zzs的题啦 ...
- 洛谷P3413 SAC#1 - 萌数(数位dp)
题目描述 辣鸡蒟蒻SOL是一个傻逼,他居然觉得数很萌! 好在在他眼里,并不是所有数都是萌的.只有满足“存在长度至少为2的回文子串”的数是萌的——也就是说,101是萌的,因为101本身就是一个回文数:1 ...
- CI框架源码学习笔记6——Config.php
接着上一节往下,我们这一节来看看配置类Config.php,对应手册内容http://codeigniter.org.cn/user_guide/libraries/config.html. clas ...
- Hystrix线程隔离技术解析-线程池(转)
认识Hystrix Hystrix是Netflix开源的一款容错框架,包含常用的容错方法:线程隔离.信号量隔离.降级策略.熔断技术. 在高并发访问下,系统所依赖的服务的稳定性对系统的影响非常大,依赖有 ...
- P2700 逐个击破
题意:现在有N个城市,其中K个被敌方军团占领了,N个城市间有N-1条公路相连,破坏其中某条公路的代价是已知的, 现在,告诉你K个敌方军团所在的城市,以及所有公路破坏的代价,请你算出花费最少的代价将这K ...
- Leetcode 70. Climbing Stairs 爬楼梯 (递归,记忆化,动态规划)
题目描述 要爬N阶楼梯,每次你可以走一阶或者两阶,问到N阶有多少种走法 测试样例 Input: 2 Output: 2 Explanation: 到第二阶有2种走法 1. 1 步 + 1 步 2. 2 ...
- C++基础学习8:类的定义(class)
先来说说C和C++中结构体的不同 a) C语言中的结构体不能为空,否则会报错(??) b) C语言中内存为空结构体分配大小为0,C++中为结构体和类分配大小为1byte c) C语言中的结构体只涉及到 ...
- __weak 和 __strong 还有Autorelease的用法
使用容器的block版本的枚举器时,内部会自动添加一个AutoreleasePool: Autorelease对象是在当前的runloop迭代结束时释放的,而它能够释放的原因是系统在每个runloop ...
- flask-SocketIO
本文来源:https://www.jianshu.com/p/d81397edd2b1 websocket是html5中实现了服务端和客户端进行双向文本或二进制数据通信的一种新协议,其实已经低于HTT ...
- 在docker容器中安装vim命令进行编辑文件
首先执行: 执行apt-get update, 然后再次执行apt-get install vim即可成功安装vim. 然后我们就可以使用vim编辑 如果不进行更新就会报错: 此时会报出bash: v ...