CF624A.Save Luke

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 _v_1 and _v_2, 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.

卢克·天行者被困在两个压板之间的垃圾粉碎机中。R2-D2 已经开始营救他,但卢克需要尽可能长时间地存活下去。为简化问题,我们假设所有事件都发生在一条直线上:两个压板初始位置分别为坐标 00 和 LL,并分别以速度 v1v_1 和 v2v_2 相向而行。卢克的宽度为 dd,且他可以在两压板之间任意选择一个位置。当两压板之间的距离小于卢克的宽度 dd 时,卢克即死亡。你的任务是计算卢克最多能存活多长时间。

输入格式

The first line of the input contains four integers d, L, _v_1, _v_2 (1 ≤ d, L, _v_1, _v_2 ≤ 10 000, d < L) — Luke's width, the initial position of the second press and the speed of the first and second presses, respectively.

输入的第一行包含四个整数 dd、LL、v1v_1、v2v_2(1 ≤ d, L, v1, v2 ≤ 10 0001 ≤ d, L, v_1, v_2 ≤ 10\,000,且 d < Ld < L)——分别表示 Luke 的宽度、第二个压板的初始位置,以及第一个和第二个压板的速度。

输出格式

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 .

输出一个实数值——Luke能够存活的最长时间。只要你的答案的绝对误差或相对误差不超过 10−610^{-6},即视为正确。

具体而言:假设你的答案为 aa,裁判组的答案为 bb。当满足条件

时,评测程序将判定你的答案正确。

输入输出样例

  • 输入#1

    2 6 2 2

    输出#1

    1.00000000000000000000
  • 输入#2

    1 9 1 2

    输出#2

    2.66666666666666650000

说明/提示

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.

在第一个样例中,卢克应恰好停留在线段的正中央,即坐标 [2;4] 处,因为两个压板以相同的速度运动。

在第二个样例中,他需要占据位置 。此时,两个压板将同时运动至他的左右边界处。

输入解题思路,AI测评打分。不知道怎么写?

首页