The Hunter
Time limit1sMemory limit128 MB
Find the shortest rope between two points outside a circle that never enters it, straight when clear and two tangents joined by an arc otherwise.
Problem
Rexxar shouts, "I will hunt you down!"
Rexxar is a legendary hunter who catches angry chickens with a harpoon tied to a rope. Rope has grown expensive lately, and that worries him.
A stone henge shaped like a cylinder of radius stands at the origin of the plain where he hunts. It is infinitely tall and solid, so the rope cannot pass through it. The rope is spun from microfibre, so its thickness is negligible, and Rexxar can throw the harpoon along any path he likes and still hit the chicken.
Rexxar stands at and the angry chicken sits at . The rope lies flat on the plain and may not enter the stone henge. Find the shortest rope that connects the two points.
Input
The first line contains the number of test cases ().
Each of the next lines contains five real numbers , , , , separated by spaces. Rexxar is at , the angry chicken is at , and the stone henge has radius (, ).
Both positions lie outside the stone henge or on its boundary, so each one is at distance at least from the origin.
Output
For each test case, print the shortest rope length on its own line, rounded at the fourth decimal place and given to three decimal places.