## GlobeX Cup '19 S2 - Predicting Collisions

View as PDF

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 . In other words, if the functions are and , find the value of such that and . 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 Specification

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

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

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

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

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

#### Output Specification

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

Note: If the official answer is and , your answer will be considered correct.

#### Constraints

For any coefficient in the input, . It is guaranteed that the leading coefficients will not be .

#### Sample Input

1
2 0
1
-1 3
0 3

#### Sample Output

1.00000000