#B4138. Card Shuffling Simulation

    ID: 11795 Type: Default 1000ms 256MiB

Card Shuffling Simulation

Card Shuffling Simulation

Given an even number n of cards numbered from 1 to n, the cards are arranged in sequential order. A shuffling operation is defined as follows:

1. Split the current deck a1, a2, \dots, an into two equal halves: a1, a2, \dots, am and am+1, am+2, \dots, an, where \( m = \frac{n}{2} \).

2. Interlace the two halves in order to form a new deck: a1, am+1, a2, am+2, \dots, am, an.

This shuffling process is repeated k times. Output the final order of the card numbers.

Note: All formulas are provided in LaTeX format.

inputFormat

The input consists of a single line containing two integers n and k separated by space. Here, n is the number of cards (an even number) and k is the number of shuffles to perform.

outputFormat

Output a single line containing the final sequence of card numbers after performing the shuffling process k times. The numbers should be separated by a single space.

sample

6 1
1 4 2 5 3 6