(二) 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;
}


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

相关文章推荐

Unity Asset - Easy Save v2.7.0p4

  • 2016年05月24日 17:37
  • 751KB
  • 下载

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...
  • zugofn
  • zugofn
  • 2016年06月06日 23:42
  • 163

Save Luke

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

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

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

数学——洛谷 P1306 斐波那契公约数

https://www.luogu.org/problem/show?pid=1306#sub 证:gcd(f(m),f(n))=f(gcd(m,n))引理1:Gcd(F[n+1],F[n])=1;...

《离散数学》加分题:已知命题p和q的真值,求他们的合取、析取、异或……

已知命题p和q的真值,求他们的合取、析取、异或、条件语句和双条件语句的真值。 从命令行输入p、q的真值,计算并输出出组合的真值...

BZOJ_P3997 [TJOI2015]组合数学(动态规划)

Time Limit: 20 Sec Memory Limit: 128 MB Submit: 549 Solved: 391 [Submit][Status][Discuss] Descr...

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

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

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

所有的命题都是一种假设,是一种经验式的或者需要验证。并不是天然就有对错。哪怕复合命题中不相干的两个(超思维),经过经验(不可能验证)发生了对应命题的陈述,也是逻辑的真,是逻辑的胜利。 例子:命题:如果...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:(二) P - P Save Luke 【数学】
举报原因:
原因补充:

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