#C222. Tracking Animal Movements
Tracking Animal Movements
Tracking Animal Movements
You are given n animals. Each animal is described by its type, initial position, and movement vector. The initial position of an animal is given as \( (x, y) \) and its movement vector as \( (dx, dy) \). For a given number m of moves, the final position of an animal is computed by applying its movement vector repeatedly:
[ \text{final position} = (x + m \cdot dx,; y + m \cdot dy) ]
Your task is to compute and output the final position of each animal after m moves.
inputFormat
The input is read from stdin and has the following format:
n m type1 x1 y1 dx1 dy1 type2 x2 y2 dx2 dy2 ... typen xn yn dxn dyn
Where:
n
is the number of animals.m
is the number of moves.- Each subsequent line describes one animal with its
type
(a string, can be ignored in computation), initial position \( (x, y) \), and movement vector \( (dx, dy) \).
outputFormat
Output the final positions of the n animals to stdout, one per line. Each line should contain two integers representing the final \( x \) and \( y \) coordinates separated by a space.
## sample2 3
deer 0 0 1 0
rabbit 2 1 0 1
3 0
2 4
</p>