CF248C.Robo-Footballer

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

It's a beautiful April day and Wallace is playing football with his friends. But his friends do not know that Wallace actually stayed home with Gromit and sent them his robotic self instead. Robo-Wallace has several advantages over the other guys. For example, he can hit the ball directly to the specified point. And yet, the notion of a giveaway is foreign to him. The combination of these features makes the Robo-Wallace the perfect footballer — as soon as the ball gets to him, he can just aim and hit the goal. He followed this tactics in the first half of the match, but he hit the goal rarely. The opposing team has a very good goalkeeper who catches most of the balls that fly directly into the goal. But Robo-Wallace is a quick thinker, he realized that he can cheat the goalkeeper. After all, they are playing in a football box with solid walls. Robo-Wallace can kick the ball to the other side, then the goalkeeper will not try to catch the ball. Then, if the ball bounces off the wall and flies into the goal, the goal will at last be scored.

Your task is to help Robo-Wallace to detect a spot on the wall of the football box, to which the robot should kick the ball, so that the ball bounces once and only once off this wall and goes straight to the goal. In the first half of the match Robo-Wallace got a ball in the head and was severely hit. As a result, some of the schemes have been damaged. Because of the damage, Robo-Wallace can only aim to his right wall (Robo-Wallace is standing with his face to the opposing team's goal).

The football box is rectangular. Let's introduce a two-dimensional coordinate system so that point (0, 0) lies in the lower left corner of the field, if you look at the box above. Robo-Wallace is playing for the team, whose goal is to the right. It is an improvised football field, so the gate of Robo-Wallace's rivals may be not in the middle of the left wall.

In the given coordinate system you are given:

  • _y_1, _y_2 — the y-coordinates of the side pillars of the goalposts of robo-Wallace's opponents;
  • y__w — the y-coordinate of the wall to which Robo-Wallace is aiming;
  • x__b, y__b — the coordinates of the ball's position when it is hit;
  • r — the radius of the ball.

A goal is scored when the center of the ball crosses the OY axis in the given coordinate system between (0, _y_1) and (0, _y_2). The ball moves along a straight line. The ball's hit on the wall is perfectly elastic (the ball does not shrink from the hit), the angle of incidence equals the angle of reflection. If the ball bounces off the wall not to the goal, that is, if it hits the other wall or the goal post, then the opposing team catches the ball and Robo-Wallace starts looking for miscalculation and gets dysfunctional. Such an outcome, if possible, should be avoided. We assume that the ball touches an object, if the distance from the center of the ball to the object is no greater than the ball radius r.

今天是四月一个美好的日子,华莱士正和朋友们一起踢足球。但他的朋友们并不知道,华莱士其实正待在家里与格罗米特相伴,派出了自己的机器人分身代替自己上场。机器华莱士相比其他球员拥有多项优势。例如,他能将球精准地踢向指定位置。然而,“传球”这一概念对他而言却完全陌生。这些特性的结合使机器华莱士成为完美的足球运动员——只要球一传到他脚下,他便只需瞄准并射门即可。上半场比赛中,他正是采用这一战术,但进球次数却寥寥无几。对方拥有一位极为出色的守门员,能拦截绝大多数直接飞向球门的射门。不过,机器华莱士思维敏捷,很快意识到自己可以“欺骗”守门员。毕竟,他们是在四周有坚实墙壁的足球场内比赛。机器华莱士可先将球踢向另一侧墙壁,此时守门员不会试图扑救;随后,若球经墙壁反弹后飞入球门,则进球终将达成。

你的任务是协助机器华莱士确定足球场墙壁上的一个点,使得机器人将球踢向该点后,球仅在此墙处反弹一次,并最终沿直线飞入球门。上半场比赛中,机器华莱士头部被球击中,遭受严重撞击,导致部分系统受损。受此损坏影响,机器华莱士目前只能瞄准其右侧墙壁(机器华莱士面朝对方球门站立)。

足球场为矩形。我们建立一个二维坐标系,使得从上方俯视球场时,坐标原点 (0,0)(0, 0) 位于场地左下角。机器华莱士所效力的球队,其球门位于右侧。这是一个临时搭建的足球场,因此对手球门未必位于左侧墙壁的正中央。

在给定的坐标系中,你已知以下参数:

  • y1y_1, y2y_2 —— 对方球门两侧门柱的 yy 坐标;
  • ywy_w —— 机器华莱士所瞄准墙壁的 yy 坐标;
  • xbx_b, yby_b —— 球被踢出时其中心的坐标;
  • rr —— 球的半径。

当球的中心在给定坐标系中穿越 OYOY 轴(即 x=0x = 0 的直线),且落点位于 (0,y1)(0, y_1) 与 (0,y2)(0, y_2) 之间时,即算作进球。球沿直线运动。球与墙壁的碰撞为完全弹性碰撞(球碰撞后不发生形变),入射角等于反射角。若球反弹后未飞向球门(即撞到其他墙壁或门柱),则对方球队将截获该球,机器华莱士随即开始排查计算错误并陷入功能紊乱。此类结果若有可能发生,必须予以避免。我们约定:当球心到某物体的距离不超过球半径 rr 时,即视为球与该物体发生接触。

输入格式

The first and the single line contains integers _y_1, _y_2, y__w, x__b, y__b, r (1 ≤ _y_1, _y_2, y__w, x__b, y__b ≤ 106; _y_1 < _y_2 < y__w; y__b + r < y__w; 2·r < _y_2 - _y_1).

It is guaranteed that the ball is positioned correctly in the field, doesn't cross any wall, doesn't touch the wall that Robo-Wallace is aiming at. The goal posts can't be located in the field corners.

第一行且唯一一行包含整数 y1y_1、y2y_2、ywy_w、xbx_b、yby_b、rr(1 ≤ y1, y2, yw, xb, yb ≤ 1061 \leq y_1, y_2, y_w, x_b, y_b \leq 10^6;y1 < y2 < ywy_1 < y_2 < y_w;yb + r < ywy_b + r < y_w;2⋅r < y2 − y12·r < y_2 - y_1)。

保证球在场地上位置正确,不穿过任何墙壁,也不接触 Robo-Wallace 正在瞄准的那面墙。球门柱不能位于场地的角落。

输出格式

If Robo-Wallace can't score a goal in the described manner, print "-1" (without the quotes). Otherwise, print a single number x__w — the abscissa of his point of aiming.

If there are multiple points of aiming, print the abscissa of any of them. When checking the correctness of the answer, all comparisons are made with the permissible absolute error, equal to 10 - 8.

It is recommended to print as many characters after the decimal point as possible.

如果罗博-华莱士无法以所述方式射门得分,则输出 “-1”(不带引号)。否则,输出一个数字 xwx_w —— 他瞄准点的横坐标。

若存在多个可行的瞄准点,则输出其中任意一个的横坐标即可。在验证答案正确性时,所有比较均允许绝对误差为 10−810^{-8}。

建议尽可能多地输出小数点后的位数。

输入输出样例

  • 输入#1

    4 10 13 10 3 1

    输出#1

    4.3750000000
  • 输入#2

    1 4 6 2 2 1

    输出#2

    -1
  • 输入#3

    3 10 15 17 9 2

    输出#3

    11.3333333333

说明/提示

Note that in the first and third samples other correct values of abscissa x__w are also possible.

注意,在第一和第三个样例中,横坐标 xwx_w 的其他正确取值也是可能的。

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

首页