(二) P - P Save Luke 【数学】

原创 2016年06月01日 09:32:12
P - P
Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0and L, and they move towards each other with speed v1 and v2, respectively. Luke has width d and is able to choose any position between the presses. Luke dies as soon as the distance between the presses is less than his width. Your task is to determine for how long Luke can stay alive.

Input

The first line of the input contains four integers dLv1v2 (1 ≤ d, L, v1, v2 ≤ 10 000, d < L) — Luke's width, the initial position of the second press and the speed of the first and second presses, respectively.

Output

Print a single real value — the maximum period of time Luke can stay alive for. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

Sample Input

Input
2 6 2 2
Output
1.00000000000000000000
Input
1 9 1 2
Output
2.66666666666666650000

Hint

In the first sample Luke should stay exactly in the middle of the segment, that is at coordinates [2;4], as the presses move with the same speed.

In the second sample he needs to occupy the position . In this case both presses move to his edges at the same time.


题意:一人的左右有两面墙,分别以v1 v2 的速度向自己移动,自己的伸展空间是d,两墙之间的宽度<d, 这个人就会死,问这人能活多长时间

题解:(l-d)/(v1+v2)

代码:

#include <cstdio>
int main()
{
    double d,l,v1,v2,time;
    while(~scanf("%lf%lf%lf%lf",&d,&l,&v1,&v2))
    {
        l=l-d;
        time=l/(v1+v2);
        printf("%.20lf\n",time);
    }
    return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

Codeforces AIM Tech Round (Div. 2) 624A A. Save Luke

A. Save Luke time limit per test1 second memory limit per test256 megabytes inputstandard input ...

Codeforces 653A: Save Luke(简单物理题)

A. Save Luke time limit per test 1 second memory limit per test 256 megabytes input...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

Save Luke

 Save Luke Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB...

【bzoj 十连测】[noip2016十连测第九场]Problem C: 小P的生成树(kruskal+数学知识)

无穷般若心自在,语默动静体自然

离散数学命题逻辑之p->q

所有的命题都是一种假设,是一种经验式的或者需要验证。并不是天然就有对错。哪怕复合命题中不相干的两个(超思维),经过经验(不可能验证)发生了对应命题的陈述,也是逻辑的真,是逻辑的胜利。 例子:命题:如果...

【BZOJ】【P2596】【Wc2007】【疯狂赛车】【题解】【数学+乱搞】

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2596 ydc大爷的题解写的很详细 http://ydcydcy1.blog.163.com...

离散数学:验证P,Q两个逻辑表达式是否逻辑等价(C语言实现)

一、程序通过编译,并实现两个命题的各种逻辑运算 二、任意输入字符串P和Q逻辑表达式的合法性检查 三、利用真值表方法验证他们的等价性

[30] Vijos P1465 进制转换(数学,vector)

容器vector很好用,另外直接用字符串初始化一个字符数组也非常便利

离散数学 p313 所有顶点都是偶度数的连通图有欧拉回路 证明

假设有连通图的每一个节点都是偶度数,却没有欧拉回路。选择其中边数最小的一个。显然G的顶点数大于1,否则只有一个偶度数顶点的图显然是有欧拉回路的。        我们先证明G一定有最少一个回路。假如v...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)