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. 即时通讯IM工具

    即时通讯IM工具,目前已知的服务及收费方式:一.专业第三方IMLeanCloud(按需收费)LeanCloud融云(免费+收费)融云即时通讯云环信(免费+收费)环信-即时通讯云领导者云之讯(免费+收费 ...

  2. IDEA注册jar包使用和常用插件

    IDEA注册jar包使用 点击获取下载地址或生成注册码 一.安装完成后,先不启动,首先如下图修改相关的地方. 二.启动IDEA,并且激活IDEA IDEA插件仓库 IntelliJ IDEA Plug ...

  3. JS-JS创建数组的三种方法

    隐式创建 var arr=["Audi","BMW","Volvo"]; 直接实例化 var arr=new Array("Aud ...

  4. BZOJ 3561 DZY Loves Math VI

    BZOJ 3561 DZY Loves Math VI 求\(\sum_{i=1}^{n}\sum_{j=1}^{m}\text{lcm}(i,j)^{\gcd(i,j)}\),钦定\(n\leq m ...

  5. JDK8漫谈——增强接口

    解决什么问题 向下兼容.添加方法,所有的实现类必须实现此方法,否则会编译报错.这意味着每一次的接口升级都会伤筋动骨.但是这是一把双刃剑一定要把握好场景,不要滥用. 类爆炸.使用时,需要辅助类.即要记忆 ...

  6. [T-ARA N4/二段横踢][Can We Love]

    歌词来源:http://music.163.com/#/song?id=26310867 Can We Love Can We Love [Can We Love Can We Love] Can W ...

  7. iptables限制连接数(如sftp) 以及 谨防CC/DDOS攻击的配置 ( connlimit模块)

    之前在公司服务器上部署了sftp,用于上传业务系统的附件.后来由于程序连接问题,使的sftp连接数过多(最多时高达400多个sftp连接数),因为急需要对sftp的连接数做严格限制.操作记录如下: 启 ...

  8. zabbix监控-基本原理介绍

    一.Linux下开源监控系统简单介绍1)cacti:存储数据能力强,报警性能差2)nagios:报警性能差,存储数据仅有简单的一段可以判断是否在合理范围内的数据长度,储存在内存中.比如,连续采样数据存 ...

  9. 毕业设计 之 五 PHP语法学习笔记

    毕业设计 之 四 PHP语法学习笔记 作者:20135216 平台:windows10 软件:XAMPP,DreamWeaver 说明:该笔记是对网站编程语言的详细学习 一.PHP基础 0. 关于环境 ...

  10. 转发:Android开发?用C#!!

    转发自 最近偶然在QQ技术群里见到有人提起用C#开发Android,当时我感觉到很诧异:Android不是只能用Java开发吗?何时可以使用C#了?那个群友便告知我:mono. 百度一下吧!搜到了mo ...