C. Robotics Competition

Codeforces
IDCF10104C
Time1000ms
Memory64MB
Difficulty
English · Original
Formal · Original
Malai advanced to the Thai national robotics contest finals, to be held next week. Each contestant specifies an instruction to her or his robot and the number of times this instruction should be executed. The robot that gets to closest to a certain target wins the contest. Each robot is represented by a point (x, y) and it starts at the origin of the plane. Each instruction is defined as I(α, ), where α is an angle in degrees and  a distance in meters. To execute instruction I(α, ), the robot must rotate α degrees counterclockwise around the origin and then move  meters to the right from its position. The image shows the execution of the instruction I(90, 10) three times. Malai is a newbie at this contest and needs your help to find the robot's final position. The first line has a single integer T, the number of test cases. Each test case contains a single line with an angle α, a distance  and an integer n, the number of times that the instruction I(α, ) must be executed. You can assume α and are rational values. *Limits* For each test case, print one line with the coordinates (x, y), in meters, of the final position of the robot, after n executions of the instruction I(α, ). The error should not be greater than 10 - 4. ## Input The first line has a single integer T, the number of test cases.Each test case contains a single line with an angle α, a distance  and an integer n, the number of times that the instruction I(α, ) must be executed. You can assume α and are rational values.*Limits* 1 ≤ T ≤ 500 0 ≤ n ≤ 109 0 ≤ α < 360 ## Output For each test case, print one line with the coordinates (x, y), in meters, of the final position of the robot, after n executions of the instruction I(α, ). The error should not be greater than 10 - 4. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $, let: - $ \alpha_k \in \mathbb{Q} $ be the rotation angle in degrees, - $ d_k \in \mathbb{Q} $ be the distance moved per instruction, - $ n_k \in \mathbb{Z} $ be the number of instruction repetitions. The robot starts at position $ (x_0, y_0) = (0, 0) $. **Constraints** 1. $ 1 \le T \le 1000 $ 2. For each test case: - $ \alpha_k \in \mathbb{Q} $, $ d_k \in \mathbb{Q} $, $ n_k \in \mathbb{Z} $, $ 1 \le n_k \le 100 $ **Objective** For each test case $ k $, compute the final position $ (x_k, y_k) $ after $ n_k $ executions of instruction $ I(\alpha_k, d_k) $: Define the rotation matrix for angle $ \theta = \alpha_k \cdot \frac{\pi}{180} $: $$ R(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} $$ The displacement vector per instruction is $ \vec{v} = \begin{bmatrix} d_k \\ 0 \end{bmatrix} $. After $ n_k $ instructions, the position is: $$ (x_k, y_k) = \sum_{i=0}^{n_k - 1} R(i \theta) \vec{v} $$ That is: $$ \begin{bmatrix} x_k \\ y_k \end{bmatrix} = d_k \sum_{i=0}^{n_k - 1} \begin{bmatrix} \cos(i \theta) \\ \sin(i \theta) \end{bmatrix} $$
API Response (JSON)
{
  "problem": {
    "name": "C. Robotics Competition",
    "description": {
      "content": "Malai advanced to the Thai national robotics contest finals, to be held next week. Each contestant specifies an instruction to her or his robot and the number of times this instruction should be execu",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10104C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Malai advanced to the Thai national robotics contest finals, to be held next week. Each contestant specifies an instruction to her or his robot and the number of times this instruction should be execu...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $, let:  \n- $ \\alpha_k \\in \\mathbb{Q} $ be the rotation angle in degrees,  \n- $ d_k...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments