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.
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.
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.
5 10 1 2 5
5.0000000000
3 6 1 2 1
4.7142857143
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(" ");} 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 }