[Solution] Deducing Sortability Codeforces Solution
Let's say Pak Chanek has an array consisting of positive integers. Pak Chanek will do a number of operations. In each operation, Pak Chanek will do the following:
- Choose an index ().
- Let be the number of operations that have been done on index before this operation.
- Decrease the value of by .
- Multiply the value of by .
After each operation, all elements of must be positive integers.
An array is said to be sortable if and only if Pak Chanek can do zero or more operations so that .
Pak Chanek must find an array that is sortable with length such that is the minimum possible. If there are more than one possibilities, Pak Chanek must choose the array that is lexicographically minimum among them.
Pak Chanek must solve the following things:
- Pak Chanek must print the value of for that array.
- questions will be given. For the -th question, an integer is given. Pak Chanek must print the value of .
Help Pak Chanek solve the problem.
Note: an array of size is said to be lexicographically smaller than an array that is also of size if and only if there exists an index such that and for each , .
The first line contains two integers and (, ) — the required length of array and the number of questions.
The -th of the next lines contains a single integer () — the index asked in the -th question.
Print lines. The -st line contains an integer representing . For each , the -th line contains an integer representing
No comments:
Post a Comment