GlobeX Cup '19 S2 - Predicting Collisions

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

The intergalactic war has started! Willie lives in a war zone and he is a soldier who wants to protect his planet. The planet's peacekeepers have gathered intel on the immediate missile launch that may affect Willie's city. This missile launch is composed of two advanced projectiles. There is a secret operation in the planet that Willie lives in. The operation involves extremely reactive substances that may destroy the planet if the two projectiles collide within a specific area. Willie would like to find the collision point of the two projectiles' paths within given boundaries. Due to Willie's dislike for Math and Physics, he has come to you for help.

For simplicity, The universe can be modelled as a 2D plane. The trajectory of each projectile can be modelled as a polynomial function. A collision is defined as a point where the two functions meet and are not tangent to each other. In other words, at a collision point, the two functions have to cross each other and not merely touch. The projectiles will not change course even if they collide because this is a new type of technology. Given the functions that represent the trajectories, find the collision point of the two projectiles within the domain [a,b]. In other words, if the functions are f(x) and g(x), find the value of x such that f(x) = g(x) and a \leq x \leq b. It is guaranteed that there is only one point in this domain where the two functions meet and that point is a collision point.

Input Specifications

Line 1: N, the degree of the first polynomial trajectory.

Line 2: N + 1 integers, separated by a single space, representing the coefficients of the first polynomial in descending order.

Line 3: M, the degree of the second polynomial trajectory.

Line 4: M + 1 integers, separated by a single space, representing the coefficients of the second polynomial in descending order.

Line 5: a and b, separated by a singe space, indicating the domain of the intersection.

Output Specifications

The first and only line of output contains the value of x, which is the x-coordinate of the intersection point.

Note: If the official answer is z and |z - x| < 10^{-8} , your answer will be considered correct.

Constraints

0 \leq N,M \leq 5

-1000 \leq a \leq b \leq 1000

For any coefficient c in the input, -1000 \leq c \leq 1000. It is guaranteed that the leading coefficients will not be 0.

Subtasks

Subtask 1 [10%]

0 \leq N,M \leq 1

Subtask 2 [20%]

0 \leq N,M \leq 2

Subtask 3 [70%]

No additional constraints.

Sample Input

1
2 0
1
-1 3
0 3

Sample Output

1.00000000

Comments

There are no comments at the moment.