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] ...
随机推荐
- Gym - 101845D 计算几何
Ignacio is a famous mathematician, some time ago he was married with Dolly, a famous scientific, at ...
- J.U.C AQS(abstractqueuedssynchronizer--同步器)
J.U.C AQS(abstractqueuedssynchronizer--同步器) 同步器是用来构建锁和其他同步组件的基础框架,它的实现主要依赖一个int成员变量来表示同步状态以及通过一个FI ...
- FMDB----SQL----数据库
#pragma mark -- 数库 - (void)createDatabase{ //路径 NSString *path = [NSString stringWithFormat:@"% ...
- freemarker 定义公共header
<#--公共顶部--> <#macro header title="默认文字" keywords="默认文字" description=&qu ...
- CodeForces - 893C-Rumor(并查集变式)
Vova promised himself that he would never play computer games... But recently Firestorm - a well-kno ...
- Java中利用JFrame创建窗体
1. 一个简单例子: public class Test(){ public static void main(String[] args){ JFrame frame = new JFrame(); ...
- log4j2重复打印日志问题解决
log4j2.xml <?xml version="1.0" encoding="UTF-8"?> <Configuration> &l ...
- mgo02_mongodb启动警告处理
** WARNING: Access control is not enabled for the database. 原因分析:新版本的MongDB增加了安全性设计,推荐用户创建使用数据库时进行验证 ...
- php数组·的方法-数组与数据结构
/*数组与数据结构*/ //shuffle() 随机打乱数组 //array_push() 数组末尾添加元素 //array_pop() 数组末尾删除元素 //array_shift() 数组首位删除 ...
- 转 Logs are not shipped to the physical standby database
http://www.oracle-ckpt.com/dataguard_troubleshoot_snapper/ ######sample primay scripts: spool dg_Pri ...