AIM Tech Round (Div. 2) A. Save Luke 水题
A. Save Luke
题目连接:
http://codeforces.com/contest/624/problem/A
Description
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 v1 and 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 .
Sample Input
2 6 2 2
Sample Output
1.000000
Hint
题意
有一个长度为L的通道,左右各有一人来抓你,速度分别是V1,V2,你的宽度是D,然后问你,你最多能存活多久
题解:
直接用(l-d)/(v1+v2)就好了,不用去管你究竟站哪儿,最久肯定是左右跑一样的时间的时候
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
double d,l,v1,v2;
cin>>d>>l>>v1>>v2;
printf("%.12f\n",(l-d)/(v1+v2));
}
AIM Tech Round (Div. 2) A. Save Luke 水题的更多相关文章
- Codeforces AIM Tech Round (Div. 2)
这是我第一次完整地参加codeforces的比赛! 成绩 news standings中第50. 我觉这个成绩不太好.我前半小时就过了前三题,但后面的两题不难,却乱搞了1.5h都没有什么结果,然后在等 ...
- AIM Tech Round (Div. 2) A
A. Save Luke time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- AIM Tech Round (Div. 2)
A. Save Luke 题意:给一个人的长度d,然后给一个区间长度0~L,给你两个子弹的速度v1,v2,两颗子弹从0和L向中间射去(其实不是子弹,是一种电影里面那种绞牙机之类的东西就是一个人被困在里 ...
- AIM Tech Round (Div. 1) D. Birthday 数学 暴力
D. Birthday 题目连接: http://www.codeforces.com/contest/623/problem/D Description A MIPT student named M ...
- AIM Tech Round (Div. 2) D. Array GCD dp
D. Array GCD 题目连接: http://codeforces.com/contest/624/problem/D Description You are given array ai of ...
- AIM Tech Round (Div. 2) C. Graph and String 二分图染色
C. Graph and String 题目连接: http://codeforces.com/contest/624/problem/C Description One day student Va ...
- AIM Tech Round (Div. 2) B. Making a String 贪心
B. Making a String 题目连接: http://codeforces.com/contest/624/problem/B Description You are given an al ...
- AIM Tech Round (Div. 2) B
B. Making a String time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- AIM Tech Round (Div. 1) C. Electric Charges 二分
C. Electric Charges 题目连接: http://www.codeforces.com/contest/623/problem/C Description Programmer Sas ...
随机推荐
- 关于nginx upstream的几种配置方式
平时一直依赖硬件来作load blance,最近研究Nginx来做负载设备,记录下upstream的几种配置方式. 第一种:轮询 upstream test{ server 192.168.0 ...
- bjfu1287字符串输出的大水题
不多说 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> # ...
- 数往知来 ASP.NET 表单的提交_url传值_重定向 <十八>
一.表单提交时注意 如果是以get方式提交数据的时候,在接收时是用QueryString方式进行接收 如果是以post请求数据时在接收时是用Form进行接收 为什么么要这样做呢?我们用Request[ ...
- MATLAB Coder从MATLAB生成C/C++代码步骤
MATLAB Coder可以从MATLAB代码生成独立的.可读性强.可移植的C/C++代码. 使用MATLAB Coder产生代码的3个步骤: 准备用于产生代码的MATLAB算法: 检查MATLAB代 ...
- JavaScript高级程序设计(第三版)第四章 变量,作用域和内存问题
JavaScript变量可以用来保存两种类型的值:基本类型值和引用类型值.基本类型值和引用类型值具有以下特点: 基本类型值在内存中占据固定大小的空间,因此被保存在栈内存中: 从一个变量向另一个变量复制 ...
- 两个实用的Python的装饰器
两个实用的Python的装饰器 超时函数 这个函数的作用在于可以给任意可能会hang住的函数添加超时功能,这个功能在编写外部API调用 .网络爬虫.数据库查询的时候特别有用 timeout装饰器的代码 ...
- Linux系统安装配置NTP时间服务器
背景 局域网不能上外网情况下同步集群时间,搭建NTP服务器,并设置其他主机每小时同步时间(假设使用地址为192.168.3.21的主机作为NTP服务器) 安装NTP $ sudo yum instal ...
- HW7.18
public class Solution { public static void main(String[] args) { int[][] m = {{1, 2}, {3, 4}, {5, 6} ...
- 第二百一十九天 how can I 坚持
今天好冷,白天在家待了一天,晚上,老贾生日,生日快乐,去海底捞吃了个火锅,没感觉呢. 今天还发现了个好游戏,纪念碑谷,挺新颖,就是难度有点大了. 好累.睡觉,明天想去爬山啊,可是该死的天气.
- python开发vim插件
[python开发vim插件] 按如下方式使用python开发vim插件,注意调用时使用的是exec. 但在函数中嵌入python代码更为简便,如下: python如何传递参数给python: 代码头 ...