Save Luke

CodeForces - 624A

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 0 and L, and they move towards each other with speed v1and 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 .

Examples

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

Note

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.

sol:小学奥数中的相遇问题。。。

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
double d,L,V1,V2;
int main()
{
scanf("%lf%lf%lf%lf",&d,&L,&V1,&V2);
printf("%.15lf\n",(double)(L-d)/(V1+V2));
return ;
}
/*
input
2 6 2 2
output
1.00000000000000000000 input
1 9 1 2
output
2.66666666666666650000
*/

codeforces624A的更多相关文章

随机推荐

  1. ddos,cc 攻击特征研究

    a.关于DDos攻击的常见方法 1. SYN Flood:利用TCP协议的原理,这种攻击方法是经典最有效的DDOS方法,可通杀各种系统的网络服务,主要是通过向受害主机发送大量伪造源IP和源端口的SYN ...

  2. oracle 相除后保留指定位数小数round()

    ) xxx from dual; XXX----------    3.8871

  3. VS2017上执行VS2013项目错误MSB802之解决方案

    进行想把我编写的数字图像处理软件MagicHouse更新到最新的VS2017开发环境下,原来的开发环境是VS2013.但是用VS2017打开项目并编译时,系统报错误MSB802,如下图所示. 其实Vi ...

  4. 基于TDA4863-2的单级PFC反激LED电源设计与仿真

    LED是一个非线性器件,正向电压的微小变化会引起电流的巨大变化:LED是一个半导体二极管,其伏安特性随温度变化而变化(-2mV/℃),假如温度升高,在恒压驱动下LED的电流会增加.长期超过额定电流工作 ...

  5. NOI.ac #8 小w、小j和小z LIS

    传送门 题意:在一个数轴上,给出$N$个人的初始位置与速度(速度有方向),求最大的时间使得存在$N-K$个人在这一段时间内两两没有相遇.$1 \leq K \leq N \leq 10^5$ 显然有二 ...

  6. LiveCharts文档-3开始-3类型和设置

    原文:LiveCharts文档-3开始-3类型和设置 LiveCharts文档-3开始-3类型和设置 类型和设置 这一部分非常的重要,涉及到LiveCharts的基本构成单元的介绍 LiveChart ...

  7. Ionic App之国际化(1)单个参数的处理

    最近的app开发中需要考虑多语言国际化的问题,经查资料,目前大部分使用的是angular-translate.js这个组件,网站说明是这个:https://angular-translate.gith ...

  8. es5中for...in 和es6中 for..of遍历

    //定义一个数组 var arr=['A','B','C']; //定义一个对象 var obj={name:'张三',age:20} // for..in 遍历数组 得到索引 for(var x i ...

  9. 一次永久解决cmd窗口汉字显示乱码

    对于编译出的程序,在 cmd 和 power shell 运行时都不能正确显示汉字. 网上查,可以再命令窗口修改: 1.打开CMD.exe命令行窗口 2.通过 chcp命令改变代码页,UTF-8的代码 ...

  10. [linux]查询多个 trace 文件中,包含特定内容的文件

    例如 目录是 /home/oracle/abc/trace 命令如下:oracle@node1 trace]$ find ./ -name "*.trc" | xargs grep ...