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 n, l, v1, 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个学生 走长度为l的行程 步行速度为v1  公车的速度v2  车上有k个位置 求最少的时间使得所有的学生到达终点;

题解:考虑什么是最优的情况呢?应该使得汽车最少的时间空车行驶,使得所有的学生坐车时间和步行时间应该相同

并且同时到达终点

上图为最优情况下 汽车的运动轨迹 保证所有的学生同时到达终点

每一个子运动的distance=v2*t-(v2-v1)/(v2+v1)*t*v2;

(t为运送第一批学生停车的时刻,返程为汽车与其余学生的相向运动)

可以发现l=p*v2*t-(v2-v1)/(v2+v1)*t*v2*(p-1); (p为学生的批数)

从而推导出t=l/(p*v2-(v2-v1)/(v2+v1)*v2*(p-1))

因为所有的学生同时到达 所以选择第一批学生计算总时间(l-v2*t)/v1+t (步行时间+坐车时间)

@dream-boy

//code  by drizzle
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
int n,k;
double l,v1,v2;
int p;
int main()
{
scanf("%d %lf %lf %lf %d",&n,&l,&v1,&v2,&k);
double L=;
p=n/k;
if((n%k)>)
p++;
L=l/(p*v2-(v2-v1)/(v2+v1)*v2*(p-));
printf("%.7f\n",(l-v2*L)/v1+L);
return ;
}

Codeforces Round #364 (Div. 2) D 数学/公式的更多相关文章

  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)

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

  4. Codeforces Round #364 (Div. 2) D. As Fast As Possible

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

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

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

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

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

  7. Codeforces Round #372 (Div. 2) C 数学

    http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel ...

  8. Codeforces Round #546 (Div. 2) E 推公式 + 线段树

    https://codeforces.com/contest/1136/problem/E 题意 给你一个有n个数字的a数组,一个有n-1个数字的k数组,两种操作: 1.将a[i]+x,假如a[i]+ ...

  9. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...

随机推荐

  1. 【luogu P1983 车站分级】 题解

    题目链接:https://www.luogu.org/problemnew/show/P1983 符合了NOIP命题的特点,知识点不难,思维量是有的. step1:把题读进去,理解.得到 非停靠点的等 ...

  2. final关键字,static关键字

    Final final的意思为最终,不可变.final是个修饰符,它可以用来修饰类,类的成员,以及局部变量.不能修饰构造方法. 注意: 被final修饰的类不能被继承但可以继承别的类 class Yy ...

  3. 问题006:为什么用java.exe执行编译的类文件的时候,不这样写java Welcome.class

    为什么用java.exe执行编译的类文件的时候,不这样写java Welcome.class 是因为java虚拟机调用Welcome的时候,已经替我们增减了.class,如果你还要写java Welc ...

  4. testC-I

    总时间限制:  20000ms 单个测试点时间限制:  1000ms 内存限制:  128000kB 描述 给你一组数,a1,a2,a3,⋯,an. 令:G=gcd(a1,a2,a3,⋯,an) 现在 ...

  5. tp5.1发送邮件

    <?php namespace app\admin\controller; use think\Controller; use think\Request; use PHPMailer\PHPM ...

  6. Mybaitis 与jdbc

    jdbc读取数据库从resultSet中遍历结果集,存在硬编码(写死的),不利于系统维护,所以最好能将结果集自动映射成java对象 由此产生了mybatis.

  7. python爬虫的基本思路

    爬虫:请求网站并提取数据的自动化程序. 流程: 发送请求 -> 获取数据 -> 解析数据 -> 存储数据

  8. Python3中的列表用法,看这一篇就够了

    类似C语言中的列表用法 ---------------------------------------------------------------------------------------- ...

  9. Appium运行时没有启动activity的权限:A new session could not be created.(Original error: Permission to start activity denied)

    小白搞appium,遇到启动不了activity的问题: 查找解决方案说是跟AndroidManifest.xml有关系,参考:https://github.com/appium/appium/iss ...

  10. 54、edittext输入类型限制为ip,inputType应该如何设置

    <EditText android:id="@+id/et_setting_printer_edit_info_ip" android:layout_width=" ...