Mock CCC '24 Contest 1 S2 - Owen the Toucan
View as PDFOnce upon a time, in a quaint village surrounded by lush forests, there lived a toucan named Owen, who was also a mathematician. Owen, being quite the playful bird, wrote down an array  on a piece of paper, consisting of a permutation of positive integers from 
 to 
. Then, he wrote down an array 
 of length 
 on the paper. The array 
 is constructed by taking the Greatest Common Divisor (GCD) of each element 
 and the corresponding element 
. Namely, 
. However, he 
purposely accidentally lost the paper and cannot remember what the arrays  and 
 were. Fortunately, he still remembers that there are exactly 
 unique integers in array 
. Can you please help him find a possible array 
?
Note: A permutation of length  is an array consisting of 
 distinct integers from 
 to 
 in any order.
Input Specification
The first line of input contains two integers  and 
.
The following table shows how the available  marks are distributed.
| Marks Awarded | ||
|---|---|---|
Output Specification
Output a possible array , a permutation of positive integers from 
 to 
.
It can be proven that there is always a valid array .
Sample Input
5 3
Sample Output
5 4 3 2 1
Explanation for Sample
The array  for sample output is 
 which is 
. In array 
, there are exactly 
 unique integers: 
, 
, and 
.
Comments