Segment and Point
InterviewTime limit1sMemory limit256 MB
Find the closest point on segment AB to point C in 3D and print the distance with ten decimals.
Problem
A segment and a point lie in three dimensional space. The endpoints of the segment are and , and the point is .
Write a program that finds the point of the segment closest to and reports that distance. This value is the minimum distance between the segment and the point.
The distance between and is .
and may be the same point. The segment is then a single point.
Input
The first line contains nine integers , , , , , , , , separated by spaces. Every coordinate is an integer between 0 and 10000, inclusive.
Output
On the first line, print the minimum distance between the segment and the point, rounded to ten digits after the decimal point. Print exactly ten digits after the decimal point whatever the value is. For example, an answer of zero is printed as 0.0000000000.