Playing Cards
Time Limit: 1 Second Memory Limit: 32768 KB
Gali comes to like playing cards recently. Here is an example of his favorite
game: at the beginning, he holds a pile of 13 cards in his hand with the face
values being 7, A, Q, 2, 8, 3, J, 4, 9, 5, K, 6, 10 from the top to the bottom.
Then he takes the top card and placed it under the bottom card. Next he takes
the current top card and puts it on the table. Gali will repeat these two steps
until there is no more card in his hand. By then Gali will find that the face
values of the cards, according to the order they have been placed on the table,
form an increasing sequence: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K.
Now let us assume that Gali has n cards in his hand, with each card numbered
from 1 to n. If he does his first step -- taking the top card and placing it
under the bottom card -- m times before doing the second step -- putting the
current top card on to the table, he wants to determine the initial order of
the cards in his hand so that after the game the sequence of the face values
of the cards on the table will be in ascending order.
Input
The input contains several test cases. Each test case consists of two positive integers n and m where 1 <= n, m <= 2000.
Output
For each test case, output the initial sequence of the n cards in a line. Separate two numbers with a single space.
Sample Input
13 1
Sample Output
7 1 12 2 8 3 11 4 9 5 13 6 10Submit
Source: ZOJ Monthly, February 2003