Codeforces Round #364 (Div. 1)A. As Fast As Possible(数学)

A. 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 kpeople (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 nlv1v2 and k (1 ≤ n ≤ 10 0001 ≤ l ≤ 1091 ≤ v1 < v2 ≤ 1091 ≤ 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.

  题解,没带笔,这个公式的推导还是用笔写一遍好,而且我决定以后题解写推导过程尽量用笔写,这样更能深入理解,更直观,而且还能练字哈哈,,

题解待补,参考了xtulollipop  文字有点少


  一不小心virtual了一下div1,就是难哈,不过这个A题是纯数学,但是我没怎么理解题意就开了,结果没计算车辆回去的时间,想了但是又把它弃了,所以推导公式错了,还费了好长时间。感觉这种纯数学题让我非常兴奋,貌似找到以前学数学的感觉了,非常好

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    int n,k;
    double l,v1,v2;
    while(~scanf("%d%lf%lf%lf%d",&n,&l,&v1,&v2,&k))
    {
        int g = n / k + (n % k != 0);
        double  a = (v1 + v2)*l/(v1+v2+2*(g-1)*v1);
        double sum = a / v2 + (l-a)/v1;
        printf("%.10f\n",sum);
    }
    return 0;
}
/*
胡乱推导过程
先送到离终点一段距离的长度
t1s
t1*v2 m
l-t1*v2//剩余的
t1m
t2s
t1+t2*v2m
(t1+t2m    …… + tn) +(l - (t1+t2++++tn)*v1)/v2//一共需要时间

t1 + (l-t1*v2)/v1
t1 + t2 + (l-(t1+t2)*v2)/v1
-t1*v2/v1==t2-(t1+t2)*v2/v1
0 == t2 - t2 *v2 /v1
1 - v2/v1 = 0
*/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值