cf700A As Fast As Possible

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个人位于数轴上0位置要走到L去,有一辆车也从0出发,只能载k个人,而且每个人都只能上车1次。人的速度都是v1,车的速度是v2,问这n个人都到达L的最小时间。

一看这输出,这小数,马上想到二分了,不然你想要怎么做(一场cf连着两题二分这很不自然)

判定我想了很久。。关键是车子可以运到一半把人赶下去叫他们自己走,然后回去载人

后来想想,如果规定了答案是ans,只要把人放在一个地方,使得你自己走过去到L的时间刚好是ans就可以了

那车子每一波载人的落点都可以算出来了

然后这题目tm还卡精度!!!我判定时再二分每次车子的落点,结果n=1w的时候精度爆了,然后wa。。

后来场外咨询(雾)换了一个判定方法(可以,这很数学)

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<cstring>
 4 #include<cstdlib>
 5 #include<algorithm>
 6 #include<cmath>
 7 #include<queue>
 8 #include<deque>
 9 #include<set>
10 #include<map>
11 #include<ctime>
12 #define LL long long
13 #define inf 0x7ffffff
14 #define pa pair<int,int>
15 using namespace std;
16 inline LL read()
17 {
18     LL x=0,f=1;char ch=getchar();
19     while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
20     while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
21     return x*f;
22 }
23 inline void write(LL a)
24 {
25     if (a<0){printf("-");a=-a;}
26     if (a>=10)write(a/10);
27     putchar(a%10+‘0‘);
28 }
29 inline void writeln(LL a){write(a);printf("\n");}
30 int n,K;
31 double l,v1,v2;
32 double now;
33 bool check(double ans)
34 {
35     double y=(l-ans*v1)/(v2-v1);
36     double s=v1*y+(v2-v1)*y/(v1+v2)*v1;
37     return (n-1)/K*s+v2*y<=l;
38 }
39 int main()
40 {
41     n=read();l=read();v1=read();v2=read();K=read();
42     if(v2<v1)v2=v1;
43     double L=l/v2,R=l/v1;
44     for(int i=1;i<=60;i++)
45     {
46         double mid=(L+R)/2;
47         if(check(mid))R=mid;
48         else L=mid;
49     }
50     printf("%.12lf",L);
51     return 0;
52 }

cf700A

时间: 2024-10-05 05:50:12

cf700A As Fast As Possible的相关文章

Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast

1.事件描述:CentOS7下使用tree命令,发现该命令没有被安装,在安装的过程中发现yum报错 [[email protected] ~]# tree -d bash: tree: 未找到命令... [[email protected] ~]# yum -y install tree 已加载插件:fastestmirror, langpacks Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast

UVA 11992(Fast Matrix Operations-线段树区间加&amp;改)[Template:SegmentTree]

Fast Matrix Operations There is a matrix containing at most 106 elements divided into r rows and c columns. Each element has a location (x,y) where 1<=x<=r,1<=y<=c. Initially, all the elements are zero. You need to handle four kinds of operati

Fast Paxos(转)

自从Lamport在1998年发表Paxos算法后,对Paxos的各种改进工作就从未停止,其中动作最大的莫过于2005年发表的Fast Paxos.无论何种改进,其重点依然是在消息延迟与性能.吞吐量之间作出各种权衡.为了容易地从概念上区分二者,称前者Classic Paxos,改进后的后者为Fast Paxos. 1. Fast Paxos概览 Lamport在40多页的论文中不仅提出了Fast Paxos算法,并且还从工程实践的角度重新描述了Paxos,使其更贴近应用场景.从一般的Client

HDU 4965 Fast Matrix Calculation 【矩阵】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4965 题目大意:给你一个N*K的矩阵A以及一个K*N的矩阵B (4 <= N <= 1000)以及 (2 <=K <= 6),然后接下来四步: 算一个新的矩阵C=A*B 算M=C^ (N*N) 对于M中的每个元素%6 将M中每个元素加起来,算出和. 也就是求出A*B * A*B * A*B * A*B * A*B *--* A*B   但是A*B形成的矩阵是N*N,而N大小有可能是10

Fast检测角点算法

1.角点定义 角点是一种局部特征,具有旋转不变性和不随光照条件变化而变化的特点,一般将图像中曲率足够高或者曲率变化明显的点作为角点.检测得到的角点特征通常用于图像匹配.目标跟踪.运动估计等方面. 2.Fast检测角点 1)基本思想 E.Rosten和T.Drummond两位大佬在06年一篇文章中提出了FAST特征算法,基本思想十分简单:以某个像素点为圆心,某半径的圆周上其他像素点与圆心像素点特性差异达到某种标准时即认为该点就是角点. 2)数学模型 经过测试发现,选取的圆形半径为3时可以兼顾检测结

Linux内核协议栈 NAT性能优化之FAST NAT

各位看官非常对不起,本文是用因为写的,如果多有不便敬请见谅 代码是在商业公司编写的,在商业产品中也不能开源,再次抱歉 This presentation will highlight our efforts on optimizing the Linux TCP/IP stack for providing networking in an OpenStack environment, as deployed at our industrial customers. Our primary go

快速近似最近邻搜索库 FLANN - Fast Library for Approximate Nearest Neighbors

What is FLANN? FLANN is a library for performing fast approximate nearest neighbor searches in high dimensional spaces. It contains a collection of algorithms we found to work best for nearest neighbor search and a system for automatically choosing t

11G新特性 -- ASM Fast Mirror Resync

ASM Fast Mirror Resync     在oracle 10g中,如果asm磁盘因为光纤.控制器发生故障而发生failure,asm将无法继续向该磁盘中写入数据.     asm会将发生failure的磁盘变为offline,等从其它冗余组同步完数据后,将该磁盘drop.asm不会再从被offline的磁盘读取数据,因为asm认为该磁盘的数据是过期的.     即使failure的磁盘被自动修复,也需要手动将磁盘重新插回重新数据同步.     1.将磁盘offline,并指定dro

OpenCV中feature2D学习——FAST特征点检测

在前面的文章<OpenCV中feature2D学习--SURF和SIFT算子实现特征点检测>中讲了利用SIFT和SURF算子进行特征点检测,这里尝试使用FAST算子来进行特征点检测. FAST的全名是:Features from Accelerated Segment Test,主要特点值计算速度快,比已知的其他特征点检测算法要快很多倍,可用于计算机视觉应用的实时场景.目前以其高计算效率(computational performance).高可重复性(highrepeatability)成为