시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 202 | 118 | 105 | 60.694% |
An Imperial Cruiser and its cohort of Tie Fighters are hot on the tail of the Millennium Falcon. The Falcon has taken minimal damage to the aft and port thrusters, but the Navi-Computer has been damaged preventing a jump to hyperspace and escape.
\( d = \sqrt{(\Delta{x})^2 + (\Delta{y})^2 + (\Delta{z})^2} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2} \)
Your task is to aid Leia in calculating the distance between two star systems with accuracy of two digits to the right of the decimal. Help save the Millennium Falcon and its crew so they can help the Rebel Alliance defeat the Empire!
The input file will begin with a line containing the integer n (0 < n < 200), representing the number of entries to process. n entries follow. An entry will consist of the name of the current star system on a line of its own, followed by the x, y, and z coordinates of that star system, all on the same line, all separated by a single space. Next will be the name of the destination star system (which is always different than the current star system) on a line of its own, followed by the x, y, and z coordinates of that star system, all on the same line, all separated by a single space.
Star system names may contain alpha-numeric characters, whitespace, and punctuation. Star system names will be no larger than 30 characters. The x, y, and z coordinates will be real numbers listed with two digits of precision to the right of the decimal point, with -100,000.00 < x, y, z < 100,000.00, thus double precision real numbers should be used to avoid rounding errors. Finally, the distance between star systems will always be at least one galactic unit.
For each entry in the input file, output on one line: the name of the current star system, then the string ‘ to ’, then the name of the destination star system, followed by a colon and a space, followed by the distance between the two systems to two digits of precision to the right of the decimal. See the sample output below for details.
2 Alderaan 1000.00 2000.00 3000.00 Dantooine -1000.00 1000.00 1000.00 Circarpous Major -500.00 500.00 -500.00 Y’Toub -500.00 -500.00 500.00
Alderaan to Dantooine: 3000.00 Circarpous Major to Y’Toub: 1414.21