Interstellar Fantasy
InterviewTime limit1sMemory limit256 MB
Given a sphere obstacle and two points outside or on it, find the shortest path length from s to t that never enters the sphere.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Implementation, Shortest path
- Solved
- No attempts yet
Problem
Unfortunately, the boy finally went bankrupt. Watching his receding figure, Rikka understood more about the world, but she is still herself. She still sat on the tower and spent time in the low gravity, feeling lost.
She looked at the deep dark sky, where the blue round Earth was shining overhead. Rikka thought about her family, her friends, and her homeland. Is she in a dream or a "real" world? The girl of chunibyo felt afraid for the first time since the journey began.
She saw a bright star traveling fast around the earth, maybe a geostationary space station. How could she get there? Daydreaming started again.
In other words, Rikka wonders about the minimum distance she needs to travel from her position to the position of the star , while a sphere, the earth, stays there as an obstacle. They are in a 3-dimensional Euclidean space. and may be at the same position.
Input
The first line contains an integer , the number of test cases. Then test cases follow.
Each test case contains two lines.
The first line contains four integers , the position in each dimension of the center of the sphere and its radius.
The second line contains six integers , the position in each dimension of the starting point and the terminal point , respectively. Note that and may be at the same position.
It is guaranteed that neither nor is strictly inside the obstacle, and each value of a position or a radius in the input belongs to .
Output
Output one number, the minimum distance from to without entering the sphere obstacle. Your answer is considered correct if the absolute or relative error doesn't exceed .