<Approximate>Paper Planes

3.6

11 votes
Algorithms, Grammar-Verified, Hard, Searching
Problem

Two paper planes are thrown upwards simultaneously. You are provided with the following data:

  • The flight time of both planes is denoted by t (seconds).
  • The initial coordinates of the first plane are denoted by (bx, by, bz).
  • The initial velocity of the first plane is denoted by (bvx, bvy, bvz).
  • The initial coordinates of the second plane are denoted by (mx, my, mz).
  • The initial velocity of the second plane is denoted by (mvx, mvy, mvz).

Write a program to find the minimum distance between the two planes during their flight. Let the jury answer be A and let your answer be B. Your answer will be considered correct if |AB|106

Input format

  • First line: t
  • Second line: Three space-separated integers (denoting bx, by, and bz)
  • Third line: Three space-separated integers (denoting bvx, bvy, and bvz)
  • Fourth line: Three space-separated integers (denoting mx, my, and mz )
  • Fifth line: Three space-separated integers (denoting mvx, mvy, and mvz)

Output format

Print the minimum distance between the two planes during their flight.

Constraints

0t10000
10000bx,by,bz10000
10000bvx,bvy,bvz10000
10000mx,my,mz10000
10000mvx,mvy,mvz10000

Sample Input
20
10 10 10
-1 -1 -1
-10 -10 -10
1 1 1
Sample Output
0.000000
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Sample Case #0: After 10 second of their flights, both plane will have same coordinate (0, 0, 0). So distance between them will be 0 at that point of time.

Editor Image

?