D. As Fast As Possible
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.

Determine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected.

Input

The first line of the input contains five positive integers nlv1, v2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 109, 1 ≤ v1 < v2 ≤ 109, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus.

Output

Print the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10 - 6.

Examples
input
5 10 1 2 5 
output
5.0000000000 
input
3 6 1 2 1 
output
4.7142857143 
Note

In the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.

题意:

有n个小学生,每个小学生的走路速度为v1,有一个汽车,速度为v2,有k个座位,每个小学生只能上一次车,问全部到达距离L的终点最短需要的时间

题解:

要想达到最短的时间,肯定只有汽车运最后一组学生和第一组学生同时到达终点,这里要好好推敲一下,画图看看,就知道求的是一个数学的追及问题

最后推出的公式可以人工求解,也可以二分

 #include<cstdio>
const double eps=1e-;
double l,v1,v2;
int n,k,g;
/*
设t'为汽车运第一组小学生的时间
可以列出一个方程:
((t'*v2-t'*v1)/(v1+v2)+t')*(g-1)*v1+t'*v2=L;
g为汽车一共要运多少次
因为只有一个未知量,并且是一次的,然后可以解出t'
然后最终的答案t=((t'*v2-t'*v1)/(v1+v2)+t')*(g-1)+t'
我不想去解上面的方程所以用二分来解出t',然后算答案
*/
bool check(double x)
{
double ans=(x*v2-x*v1)/(v1+v2)+x;
ans=ans*(g-)*v1+x*v2;
if(ans>l+eps)return ;
return ;
} double fuck()
{
double ll=,rr=l/v1,m;
for(int i=;i<=;i++)
{ m=(ll+rr)/;
if(check(m))ll=m;else rr=m;
}
return ll;
} int main()
{
scanf("%d%lf%lf%lf%d",&n,&l,&v1,&v2,&k);
g=n/k+(n%k!=);
double an=fuck(),ans;
ans=(an*v2-an*v1)/(v1+v2)+an;
ans*=(double)(g-);
ans+=an;
printf("%.10lf\n",ans);
return ;
}

Codeforces Round #364 (Div. 2) D. As Fast As Possible的更多相关文章

  1. Codeforces Round #364 (Div.2) D:As Fast As Possible(模拟+推公式)

    题目链接:http://codeforces.com/contest/701/problem/D 题意: 给出n个学生和能载k个学生的车,速度分别为v1,v2,需要走一段旅程长为l,每个学生只能搭一次 ...

  2. Codeforces Round #364 (Div. 2) D. As Fast As Possible 数学二分

    D. As Fast As Possible 参考:https://blog.csdn.net/keyboardmagician/article/details/52769493 题意: 一群大佬要走 ...

  3. 【推导】Codeforces Round #364 (Div. 2) D. As Fast As Possible

    一种方法是二分总时间,复杂度O(nlogn). 另外我们可以证明,当所有人同时到达终点的时候,是最优的,因为没有人的时间“浪费”了. 我们又发现,每个人的运动过程总是两段,要么是走路,要么是坐车.于是 ...

  4. codeforces 700a//As Fast As Possible// Codeforces Round #364(Div. 1)

    题意:n个人要运动ll长,有个bus带其中几个人,问最短时间 最后所有人在同一时间到终点是用时最少的.由于搭bus相当于加速,每个人的加速时间应该一样.先计算bus走过的路程route.看第一个人被搭 ...

  5. Codeforces Round #364 (Div. 2)

    这场是午夜场,发现学长们都睡了,改主意不打了,第二天起来打的virtual contest. A题 http://codeforces.com/problemset/problem/701/A 巨水无 ...

  6. Codeforces Round #364 (Div.2) C:They Are Everywhere(双指针/尺取法)

    题目链接: http://codeforces.com/contest/701/problem/C 题意: 给出一个长度为n的字符串,要我们找出最小的子字符串包含所有的不同字符. 分析: 1.尺取法, ...

  7. 树形dp Codeforces Round #364 (Div. 1)B

    http://codeforces.com/problemset/problem/700/B 题目大意:给你一棵树,给你k个树上的点对.找到k/2个点对,使它在树上的距离最远.问,最大距离是多少? 思 ...

  8. Codeforces Round #364 (Div. 2) D 数学/公式

    D. As Fast As Possible time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. Codeforces Round #364 (Div. 1)(vp) 没什么题解就留坑待填

    我就做了前两题,第一题第一次vp就把我搞自闭跑路了,第二题第二次又把我搞自闭了 A. As Fast As Possible 细节题 #include<cstdio> #include&l ...

随机推荐

  1. 郑州尚学堂:如何在Java中创建对象

    作为Java开发者,每天都会创建大量的对象,但是,我们总是使用管理依赖系统(如Spring框架)来创建这些对象.其实还有其他方法可以创建对象,在接下来的文章中我会进行详细介绍. 1.使用new关键字 ...

  2. 分布式版本控制系统Git-----5.Git 的push命令总结

    git push git push命令用于将本地分支的更新,推送到远程主机.它的格式与git pull命令相仿. git push <远程主机名> <本地分支名>:<远程 ...

  3. seajs简记

    参考seajs快速入门 一.前端模块化的价值 解决命名冲突 摆脱文件依赖 性能优化 提高可维护性 seajs.use方法调用通过exports暴露接口通过require引入依赖 二.Sea.js 的常 ...

  4. 2016 Technology

    rem 62.5%在chrome谷歌和其他浏览器不一样 http://www.5imoban.net/jiaocheng/div+css/201512191529.html http://blog.c ...

  5. IQueryable和IEnumerable,IList的区别

    IQueryable和IEnumerable都是延时执行(Deferred Execution)的,而IList是即时执行(Eager Execution) IQueryable和IEnumerabl ...

  6. 《JS权威指南学习总结--第八章 函数》

    内容要点: 一.JS函数是参数化的:函数的定义会包括一个称为形参的标识符列表,这些参数在函数体中像局部变量一样工作.函数调用会为形参提供实参的值.函数使用它们实参的值来计算返回值,成为该函数调用表达式 ...

  7. apt-get 安装路径

    apt-get安装目录和安装路径:apt-get 下载后,软件所在路径是:/var/cache/apt/archivesubuntu 默认的PATH为PATH=/home/brightman/bin: ...

  8. 图的两种遍历:DFS&BFS

    DFS和BFS在图中的应用: 图连通性判定:路径的存在性:图中是否存在环:求图的最小生成树:求图的关键路径:求图的拓扑排序. DFS:简单的说,先一直往深处走,直到不能再深了,再从另一条路开始往深处走 ...

  9. 使用JavaScript进行数组去重——一种高效的算法

    最近比较忙,没时间更新博客,等忙完这阵子会整理一篇使用AngularJS构建一个中型的单页面应用(SPA)的文章,尽情期待!先占个坑. 数组去重的算法有很多种,以下是一种. 思路如下: 定义一个空的对 ...

  10. Struts国际化

    第一步需要建立配置文件 格式为      文件名_zh_CN.properties    为中文配置文件   文件名_en_US.properties为美式英语配置文件 配置文件里面的值以键值对的形式 ...