Canadian Computing Competition: 2021 Stage 1, Senior #5
Your math teacher has given you an assignment involving coming up with a sequence of integers , such that for each .
The sequence must also satisfy requirements, with the one stating that the GCD (Greatest Common Divisor) of the contiguous subsequence () must be equal to . Note that the GCD of a sequence of integers is the largest integer such that all the numbers in the sequence are divisible by .
Find any valid sequence consistent with all of these requirements, or determine that no such sequence exists.
The first line contains two space-separated integers, and . The next lines each contain three space-separated integers, , , and ().
The following table shows how the available marks are distributed.
| Subtask | |||
|---|---|---|---|
| 3 marks | for each | ||
| 4 marks | for each | ||
| 8 marks | for each |
If no such sequence exists, output the string Impossible on one line. Otherwise, on one line, output space-separated integers, forming the sequence . If there are multiple possible valid sequences, any valid sequence will be accepted.
If and , the GCD of is and the GCD of is , as required. Please note that other outputs would also be accepted.
There exists no sequence such that the GCD of is and the GCD of is .
No comments yet. Be the first to comment!