← Home
write a go solution for Description:
You have an array a_0,a_1,ldots,a_n-1 of length n. Initially, a_i=2^i for all 0<=iltn. Note that array a is zero-indexed.

You want to reverse this array (that is, make a_i equal to 2^n-1-i for all 0<=iltn). To do this, you can perform the following operation no more than 250,000 times:

- Select an integer i (0<=iltn) and replace a_i by a_ioplusa_(i+1)bmodn.

Here, oplus denotes the bitwise XOR operation.

Your task is to find any sequence of operations that will result in the array a being reversed. It can be shown that under the given constraints, a solution always exists.

Input Format:
The first line contains a single integer n (2<=n<=400) — the length of the array a.

Output Format:
On the first line print one integer k (0<=k<=250,000) — the number of operations performed.

On the second line print k integers i_1,i_2,ldots,i_k (0<=i_jltn). Here, i_j should be the integer selected on the j-th operation.

Note that you don't need to minimize the number of operations.

Note:
In the notes, the elements on which the operations are performed are colored red.

In the first test case, array a will change in the following way:

[1,colorred2]arrow[colorred1,3]arrow[2,colorred3]arrow[2,1].

In the second test case, array a will change in the following way:

[1,colorred2,4]arrow[colorred1,6,4]arrow[7,colorred6,4]arrow[colorred7,2,4]arrow[5,2,colorred4]arrow[5,colorred2,1]arrow[colorred5,3,1]arrow[6,colorred3,1]arrow[colorred6,2,1]arrow[4,2,1].. Output only the code with no comments, explanation, or additional text.