Hide

Problem E
Exoplanet Lighthouse

As humanity travels to extraterrestrial bodies, the need for human or robotic explorers to determine their location on the surface will be critical. Lighthouses offer a simple solution as line-of-sight navigational beacons. An important measurement for lighthouses is geographic range, the maximum visible, line-of-sight distance between an observer and the lighthouse before the lighthouse is obscured by the horizon due to the curvature of the surface. The surface traveling distance corresponding to the geographic range is crucial for planning fuel and oxygen supplies to ensure an accurate—and safe—return to base stations.

Your team is to write a program that computes the maximum surface distance that allows for a line-of-sight between an observer and a lighthouse. Your program is to assume that exoplanets are spherical with a known radius.

\includegraphics[width=0.5\textwidth ]{lighthouse.png}


Input

The first line of input contains a single integer $t$ ($1 \le t \le 20$), which is the number of test cases.

Each of the next $t$ lines is a separate test case which contains three real numbers:

$R$ ($100 \le R \le 20\, 000$), $h_1$ and $h_2$ ($1 \le h_1,h_2 \le 1\, 000$)

Where $R$ is the radius of the exoplanet in kilometers, $h_1$ is the height above the surface of the exoplanet of the observer in meters, and $h_2$ is the height of the lighthouse beacon above the surface of the planet in meters.

Output

Output $t$ lines, one for each test case. On each line output a single real number, $D$, which is the maximum distance in kilometers on the surface of the exoplanet, measured from the base of the observer to the base of the lighthouse, that allows for a line-of-sight between the observer and the lighthouse beacon. The answer must be accurate to within one meter.

Sample Input 1 Sample Output 1
4
6371.0 1.0 27.0
6371.0 1.0 26.99
6371 1.0 1.0
1737.4 1 27
22.117714375394343
22.114279232261655
7.139187161948777
11.550070205049764

Please log in to submit a solution to this problem

Log in