Cf 364div2 D[数学公式推导]
2016-08-01 20:54
302 查看
题目连接
http://codeforces.com/contest/701/problem/DDescription
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.Sample Input
3 6 1 2 1Sample Output
4.7142857143题意
开始的时候还没弄懂题意,以为就是一个追击问题的极限形式,但是样例都对不上。还有就是这句话as well as the reversal of the bus,我以为是返回的时候也是不要时间的意思,但是好像应该是车掉头不要时间 -。- …题意就是一群学生要到一个目的地去,他们当中没人可以有一次坐车的机会,问怎么才能使用的总时间最少。
题解
所用的总时间最少应该是大家都同时到达,没有人在终点等待其他人,也就没有时间浪费掉。在大家都同时到达的情况下,那么每人乘车的时间和步行的时间应该是相同的。要注意的double运算的时候,要保证每一个部分都是double,某些时候要强制转换。推导
设某人1处在x的位置,某人2乘车的距离为a,车送完某人2返回去接某人1的时间为t。一个要接g=n/k[分偶数奇数讨论+1or not +1]组人
x+t*v1=x+a-(t-a/v2)化简得 t= (2 *a)/(v1+v2)
最后一个人在车上与其他所有人同时到达终点,那么车行驶的时间与一个人所用的总时间是相同的则
a/v2 + t*(g-1)=a/v2 +(l-a)/v1 化简得 a=(v1+v2) *l/(2 *g *v1+v2-v1)
t=a/v2+(l-a)/v1
代码
#include<bits/stdc++.h> using namespace std; int main() { int n,l,v1,v2,k; scanf("%d%d%d%d%d",&n,&l,&v1,&v2,&k); int g; if(n%k==0){g=n/k;} else g=(n/k)+1; double a=((double)(v1+v2)*l)/(2*g*v1+v2-v1); double t=a/v2+(l-a)/v1; printf("%.10lf",t); }
相关文章推荐
- 51nod 1417 天堂里的游戏[数学公式推导]
- BP神经网络的数学公式推导
- n阶乘后面0的个数+组合数学结果0的个数举例+公式推导
- 根据经纬度计算地面两点间的距离-数学公式及推导
- CF 934D 数学 推导多项式展开
- Codeforces 534C Polycarpus' Dice(数学,公式推导)
- CF#368 C. Pythagorean Triples (数学/推导公式)
- 453. Minimum Moves to Equal Array Elements 数学公式推导
- Lucene学习总结之六:Lucene打分公式的数学推导
- 关于Online Judge题目tick and tick的数学公式推导
- 双层神经网络与逻辑回归正反向传播数学公式简要推导
- Lucene学习总结之六:Lucene打分公式的数学推导
- HDU 4586 Play the Dice (数学,公式推导)
- SVM数学公式推导及个人总结
- Newton冷却定理微分数学公式推导
- 常用数学公式推导及概念
- poj 3761 Panda's Birthday Present (数学公式推导~~推?)
- hdu 5584 LCM Walk(数学推导公式,规律)
- [HDOJ5734]Acperience(数学,公式推导)
- Lucene学习总结之六:Lucene打分公式的数学推导