Time limit: 1.0s
Memory limit: 256M
To test his divide and conquer abilities, Max decided to try a new technique of splitting his array, , of integers into equally-sized segments and reassembling them in a new order:
- If the current segment is element, return it.
- Otherwise, split the current segment into segments and apply the technique again on each segment. After applying the technique again, he will take the first segment and move it to the second segment's position, the second segment and move it to the third segment's position, and finally, the third segment and move it to the first segment's position. Finally, return this new segment.
If , he will split it into segments: .
Then, he will split each segment again: , , .
Now, merge each segment based on those rules: , , .
Finally, merge once more and get the final array: .
Can you find the final array after applying this technique?
will be a power of .
The first line will contain an integer, , the number of array elements.
The second line will contain integers, , the elements of the array.
Output the array after applying this technique.
9 1 2 3 4 5 6 7 8 9
9 7 8 3 1 2 6 4 5