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的更多相关文章
随机推荐
- JavaScript中的slice函数
String.slice(start,end)returns a string containing a slice, or substring, of string. It does not mod ...
- Java多线程编程模式实战指南一:Active Object模式(上)
Active Object模式简介 Active Object模式是一种异步编程模式.它通过对方法的调用与方法的执行进行解耦来提高并发性.若以任务的概念来说,Active Object模式的核心则是它 ...
- 解决Oracle登录极慢的问题
原文首发 http://anforen.com/wp/2018/04/oracle_login_slowly/ Oracle用PL/SQL登录,特别慢,3分钟以上,如果以前正常,并且按常见问题排查过, ...
- Luogu P3177 [HAOI2015]树上染色
一道有机结合了计数和贪心这一DP两大考点的神仙题,不得不说做法是很玄妙. 首先我们很容易想到DP,设\(f_{i,j}\)表示在以\(i\)为根节点的子树中选\(j\)个黑色节点的最大收益值. 然后我 ...
- nginx解决前端跨域配置
在nginx.conf文件中 添加如上配置: 在ajax中将原来的 url:http://192.168.1.127:8905/findItem 改成:'http://localhost/findIt ...
- Python基础(上)
前言 正式开始Python之旅,主要学习内容专注在爬虫和人工智能领域,如Web开发之类将跳过不研究. Python的意思是蟒蛇,源于作者Guido van Rossum(龟叔)喜欢的一部电视剧.所以现 ...
- php类之clone 克隆
对象也能被“克隆” 在php5中,对象的传递方式默认为引用传递,如果我们想要在内存中生成两个一样的对象或者创建一个对象的副本,这时可以使用“克隆”. 通过 clone 克隆一个对象 对象的复制是通过关 ...
- use_frameworks!和#use_frameworks!的区别、解决Swift项目中use_frameworks!冲突的问题
use_frameworks!和#use_frameworks!的区别 转自:https://www.jianshu.com/p/0ae58a477459 1. 用cocoapods 导入swift ...
- 全景3d
Three.js Tour.js Run.js 3D Css3 酷家乐:https://www.kujiale.com/ 爱空间:http://bj.ikongjian.com/?utm_source ...
- 【Beta阶段】第九次Scrum Meeting!(论坛已成功上线)
每日任务内容: 本次会议为第九次Scrum Meeting会议~ 本次会议为团队项目第九次会议,在会议前大家取得了重大成果! 队员 昨日完成任务 明日要完成任务 刘乾 #179 完成1021的数据处理 ...