codeforces624A
Save Luke
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 d, L, v1, v2 (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
2 6 2 2
1.00000000000000000000
1 9 1 2
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的更多相关文章
随机推荐
- AI 朴素贝叶斯分类
1.条件概率 P(A|B)表示在事件B已经发生的条件下,事件A发生的概率.计算公式:P(A|B)=P(AB)/P(B). 2.相互独立事件 对于相互独立事件A和B,它们发生的概率互不影响,P(AB)= ...
- 《Head First 设计模式》[02] 观察者模式
1.观察者模式 1.1 形象地认识观察者模式 报社的业务是出版报纸 用户像某家报社订阅了报纸,那么一旦报社有新的报纸,就会送到用户处.只要是订户,就一直会收到新报纸: 当用户不再想看报纸时,取消订阅, ...
- 人生苦短之学习Python50本书籍(包涵基础、算法、机器学习、模块、爬虫框架、树莓派等)总有你想要的书籍
很多小伙伴说想学习想学习但是没有学习书籍,我给大家分享一大波学习书籍,具体的可以自己往下翻 <"笨办法学"Python3> Zed Shaw 著 (2018年5月) ...
- LVDS时序分析
LVDS时序分析 2012年05月07日 11:48:08 Walle 阅读数:3355 标签: 平台工作 最近在调试基于telechip平台的LVDS驱动,一开始对该平台的LVDS时序不是很了解 ...
- Luogu2612 ZJOI2012 波浪 DP
传送门 花掉了自己用来搞学科的时间做了这道题-- 一道类似的题:Here 考虑拆开绝对值计算贡献.那么我们对于\(1\)到\(N\)的排列,从小到大地将插入它们插入排列中. 假设我们现在计算到了数\( ...
- C#winform中调用wpf
原文:C#winform中调用wpf 在WinForm中是可以使用WPF中的控件(或者由WPF创建的自定义控件) 1.新建一个winform项目: 2.在解决方案上新建一个wpf项目: 如图: 如果有 ...
- 一个有趣的问题——HTTP是“超文本传输协议”还是“超文本转移协议”
最近在看<HTTP图解>这本书,书中提到了对国内对HTTP协议名称的翻译问题,并且给出了一些网友讨论的原稿链接,我看了一下觉得挺有意思的,另外我本人也觉得翻译对于理解协议本身非常重要,就整 ...
- BootStrap学习(3)_导航菜单
一.导航元素 1.表格导航或标签 以一个带有 class .nav 的无序列表开始. 添加 class .nav-tabs. <!DOCTYPE html> <html xmlns= ...
- Verilog设计异步FIFO
转自http://ninghechuan.com 异步FIFO有两个异步时钟,一个端口写入数据,一个端口读出数据.通常被用于数据的跨时钟域的传输. 同步FIFO的设计.一个时钟控制一个计数器,计数器增 ...
- 【调试技巧】 Fiddler高级用法之url映射请求
问题场景: 已发布线上APP出现接口错误,如何测试线上APP访问本地请求? 已发布线上H5页面,静态资源或js调试,如何映射本地js? 一般解决方案: 猜测(一般明显问题). 找到原发布包,修改请求资 ...