121. Space Invaders

Codeforces
IDCF10269121
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
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: 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. 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 $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. ## 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. [samples]
**Definitions** Let $ (X, Y, Z) \in \mathbb{R}^3 $ be the coordinates of the spaceship. Let $ n \in \mathbb{Z}^+ $ be the number of aliens. For each $ i \in \{1, \dots, n\} $, let $ (x_i, y_i, z_i) \in \mathbb{R}^3 $ be the coordinates of the $ i $-th alien. **Constraints** 1. $ n \geq 1 $ 2. All coordinates are real numbers (given as integers, but treated as reals for distance calculation). **Objective** For each alien $ i $, compute the Euclidean distance $ d_i $ from the spaceship: $$ d_i = \sqrt{(x_i - X)^2 + (y_i - Y)^2 + (z_i - Z)^2} $$ Output $ d_1, d_2, \dots, d_n $, one per line.
API Response (JSON)
{
  "problem": {
    "name": "121. Space Invaders",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269121"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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.\n\nIn three dimensions...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ (X, Y, Z) \\in \\mathbb{R}^3 $ be the coordinates of the spaceship.  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of aliens.  \nFor each $ i \\in \\{1, \\dots, n\\} $, let $ (x_i, y_i, z...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments