Two spheres drift on straight paths at constant speeds, and you compute the first instant their surfaces touch or report no collision.
Easy3MathGeometryInterviewNo attempts yetTime limit4sMemory limit256 MBAccording to NASA's web page, more than 500 000 pieces of space junk are tracked. Mission planning has to keep satellites and other spacecraft from running into those pieces.
This problem uses a simplified model in which the spacecraft and the piece of space junk are both spheres moving along a straight line at constant velocity. Given the current position, radius and velocity of each sphere, find the time at which the two spheres first collide. The collision happens the moment their surfaces first touch, that is, the earliest time at which the distance between the two centers equals the sum of the two radii.
The first line contains the number of test cases T (1≤T≤500).
Each test case consists of two lines. The first line describes the sphere representing the spacecraft and the second line describes the sphere representing the space junk. Each sphere is given by seven integers x, y, z, r, vx, vy, vz. The center of the sphere is currently at (x,y,z), its radius is r, and it travels along the direction vector (vx,vy,vz). If that vector is (0,0,0), the sphere is stationary.
The absolute value of every integer is at most 100, and r is positive. Coordinates and radii are measured in meters, and velocities in meters per second.
The two spheres do not touch each other initially.
For each test case, print on its own line the time in seconds at which the spacecraft first collides with the space junk. Round the value to exactly three digits after the decimal point and keep trailing zeros. If the two spheres never collide, print No collision instead.
The input is chosen so that the value rounded to three decimal places is unambiguous.