Problem C
Spilahlustun
Languages
en
is
Jörmunrekur’s wallet has gotten frightfully light towards
the end of his studies, so he is looking for creative ways to
fix that problem. After taking a course in probability theory
he knows that most betting games played with a deck of cards
will not be in his favour unless he has some trick up his
sleeve. And that he does, he has gotten himself a small
microphone which he will attach to the underside of the table
at which he is playing. The cards are shuffled using a small
automatic machine to make sure things are fair. The machine is
silent enough to not be heard by even the most perceptive of
people and does its work outside the view of the players. It
shuffles by taking some section of the cards and flipping the
section over as a whole before inserting it back into the deck,
repeating as often as necessary. After shuffling, when dealing
the cards, it simply turns the card over as it deals, if the
card is upside down. Through the microphone Jörmunrekur can
pick up the imperceptibly silent sounds of the shuffler, giving
away how far it moves before picking up a section to flip, and
how much the grabber has to widen to get a hold of that
section. Thus he can know what section is flipped each time.
But he has to focus on the game, he does not need to know what
sections get flipped, he needs to know in what order the cards
will be dealt. He needs a program to take care of this for him,
are you up to the task? We number the cards from
Input
The first line of input contains two integers
Output
Print the numbers of the cards from top to bottom, as they
are ordered at the end of the shuffle. If card
Sample Input 1 | Sample Output 1 |
---|---|
5 1 2 4 |
1 -4 -3 -2 5 |
Sample Input 2 | Sample Output 2 |
---|---|
7 6 1 3 3 7 2 3 4 7 1 1 4 4 |
3 7 2 1 4 5 6 |