You are working as a cryptographer in a post-apocalyptic world. The most common form of information is transmitted in messages with cyclic arrays of size
Constraints
Subtask 1 [5%]
Subtask 2 [15%]
Subtask 3 [20%]
If
Subtask 4 [60%]
No additional constraints.
Input Specification
The first and only line contains
Output Specification
If it is impossible to create a valid message, output 0
. Otherwise, output
Note: your output must follow the standard convention of not having any leading or trailing whitespace, and it must end with a new line.
Sample Input
8 3
Sample Output
-1 -1 1 1 -1 1 -1 1
Explanation
The diagram below shows the cyclic array, with the indices labeled below the elements.
The following list shows the product of every cyclic subarray of length
The product of elements from index
The product of elements from index
The product of elements from index
The product of elements from index
The product of elements from index
The product of elements from index
The product of elements from index
The product of elements from index
Summing, we get
Comments