If it's a Javelin, Duck!
Time Limit: 2 Seconds
Memory Limit: 65536 KB
The coaches for the US Olympic Track Team, Pierre A. Noid and Ada Noid, fear
that their 16-year-old, 7'2" javelin thrower, Moven van Driver, has not
been given a "fair go" by the Olympic referees. They have purchased
two distance measuring devices (DMD) to help them check on the accuracy of the
measurements made by the referees. There are several elimination rounds for
which each coach positions him/herself in either coaches area (which includes
the boundaries), such that the two coaches are on opposite sides of the throwing
zone. At the beginning of each round the coaches measure their separation from
each other and the distance of each from the launching point. During a round
the coaches do not move. For each throw in each round they record their distances
from the landing point, and calculate the distance that should have been awarded
to Moven. You may assume that the javelin will always land somewhere in the
landing area (which includes its boundary).
The following measurements are made, as indicated in the figure above:
x Pierre's distance from the launching point
y Ada's distance from the launching point
z distance between Ada and Pierre
a Pierre's distance from the javelin's landing point.
c Ada's distance from the javelin's landing point.
Your program is to determine b, the actual distance traveled by the javelin
(in meters, to the nearest hundredth of a meter) from the other measurements
(given in meters to the nearest hundredth of a meter).
There will be several groups of input data, each representing a round. The first
line of each group will have an integer and three real numbers, n, x, y, and
z separated by white space. The first number n is the number of throws in the
current round, such that 0 <= n <= 5. The other distance limits are 10
<= x <= 100, 10 <= y <= 100, and 5 <= z <= 100. The next n
lines will have pairs of real numbers, representing measurements a and c, such
that 0 <= a <= 100, and 0 <= c <= 100. The input data is terminated
by a value of n = 0, followed by three zeros, and this data is not processed.
The output should be labeled by the number of the round, and followed by the
distance of each throw for that round (each on a separate line). Formatting
should be as in the sample output.
3 50.00 50.00 75.00
2 30.00 60.00 87.50
0 0 0 0
Source: Southeast USA 2000