407150: GYM102697 121 Space Invaders

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

121. Space Invaderstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You're traveling through space in your spaceship, when your ship's radar detects several hostile aliens near the ship. You need to figure out how close each alien is to your ship.

In three dimensions, the distance between two points, each with an X, Y, and Z coordinate, is defined as follows:

$$$D$$$ = $$$\sqrt{(X2-X1)^2 + (Y2-Y1)^2 +(Z2-Z1)^2}$$$

Given the coordinates of your ship, in 3D space, figure out how far away each alien is from your ship, using the formula described above.

Input

The first line of input contains three space-separated integers $$$X$$$, $$$Y$$$, and $$$Z$$$: the coordinates of your ship in 3D space. The next line of input contains a positive integer $$$n$$$ indicating the number of aliens that have been detected by the ship's radar. The next $$$n$$$ lines each contain three space-separated integers, each representing the coordinates of an alien.

Output

Output $$$n$$$ lines. On each line, output a single decimal number: the distance between your ship and each alien, in the order given in the input. You don't need to round your answers.

ExamplesInput
7 3 8
6
2 1 5
3 7 6
4 2 1
9 8 4
7 3 8
5 11 16
Output
6.164414002968976
6.0
7.681145747868608
6.708203932499369
0.0
11.489125293076057
Input
2 4 6
3
-2 -4 -6
2 -4 -6
-2 4 6
Output
14.966629547095765
14.422205101855956
4.0

加入题单

算法标签: