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的更多相关文章
随机推荐
- lmbench性能分析工具
下载地址 http://www.bitmover.com/lmbench/ tar -zxvf lmbench3.tar.gz cd lmbench3 make 此时会报错: make[2]: *** ...
- QT pri 文件的作用
i 是什么东西?包含(include)的首字母.类似于C.C++中的头文件吧,我们可以把 *.pro 文件内的一部分内容单独放到一个 *.pri 文件内,然后包含进来. 接前面的例子,我们将源文件的设 ...
- 安全提示:IIS不要开启“WebDAV”扩展(转载)
在IIS设置里,有一个“Web服务扩展”的设置,其中包括“WebDAV”扩展.许多人都不明白,这个“WebDAV”扩展是干嘛用的,要不要开启呢?有不少人的想法是“开启吧,以免影响网站运行,启用总比不启 ...
- 【转】分布式一致性算法:Raft 算法(Raft 论文翻译)
编者按:这篇文章来自简书的一个位博主Jeffbond,读了好几遍,翻译的质量比较高,原文链接:分布式一致性算法:Raft 算法(Raft 论文翻译),版权一切归原译者. 同时,第6部分的集群成员变更读 ...
- Verilog设计异步FIFO
转自http://ninghechuan.com 异步FIFO有两个异步时钟,一个端口写入数据,一个端口读出数据.通常被用于数据的跨时钟域的传输. 同步FIFO的设计.一个时钟控制一个计数器,计数器增 ...
- 【福利】送Spark大数据平台视频学习资料
没有套路真的是送!! 大家都知道,大数据行业spark很重要,那话我就不多说了,贴心的大叔给你找了份spark的资料. 多啰嗦两句,一个好的程序猿的基本素养是学习能力和自驱力.视频给了你们,能不能 ...
- TomCat 再次发布我的程序
打包成.war的步骤就不说了,之后的配置和上一次的不一样. 在Tomcat的conf下的server.xml文件中,重新配置如下 <Service name="xfwweb" ...
- 针对Nginx日志的相关运维操作记录
在分析服务器运行情况和业务数据时,nginx日志是非常可靠的数据来源,而掌握常用的nginx日志分析命令的应用技巧则有着事半功倍的作用,可以快速进行定位和统计. 1)Nginx日志的标准格式(可参考: ...
- 如何新增一个ssh-key文件
前言 由于在公司有一个sshkey 在用,用于绑定公司的git code 仓库.那么在家要连上git hub 仓库,就也需要一个 ssh key .为了避免公司信息外露,所以还是新增一个ssh key ...
- 个人作业——final
一 . 对M1M2的一个总结 我特别感谢我们组的PM.以前我觉得女生学计算机这个专业,跟男生比差太远了.总觉得我们女生就是上上课写写作业考考试还行,但是一到开发什么项目啊,实战之类的,总觉得自己的能力 ...