题目描述
Shuffling is a procedure used to randomize a deck of playing cards.
Because standard shuffling techniques are seen as weak, andin order to
avoid "inside jobs" where employees collaborate with gamblers
by performing inadequate shuffles, many casinos employ automatic
shuffling machines
. Your task is to simulate a shuffling machine.
The machine shuffles a deck of54 cards according toa given random
order and repeats fora given numberof times. It is assumed that the
initial status ofa card deck is inthe following order:
S1, S2, ..., S13,
H1, H2, ..., H13,
C1, C2, ..., C13,
D1, D2, ..., D13,
J1, J2
where "S" stands for"Spade", "H"for"Heart", "C"for"Club", "D"for"Diamond", and"J"for"Joker". A given
order is a permutation of distinct integers in [1, 54]. If thenumberatthe i-th position is j, it means to move the card from position i to
position j. For example, suppose we only have 5 cards: S3, H5, C1, D13
and J2. Given a shuffling order {4, 2, 5, 3, 1}, theresult will be:
J2, H5, D13, S3, C1. If we are torepeatthe shuffling again, theresult will be: C1, H5, S3, J2, D13.
输入描述:
Each input filecontainsone test case. For eachcase, thefirstlinecontainsa positive integer K (<= 20) which is thenumberofrepeat times. Then the next linecontainsthe given order. All the numbers inaline are separated byaspace.
输出描述:
For each test case, print the shuffling results inoneline. All the cards are separated byaspace, and there must be no extra spaceattheendoftheline.
输入例子:
2365237383394053544111121342434424232425262767848495051910141516517181912021222829303132333435454647
输出例子:
S7 C11 C10 C12 S1 H7 H8 H9 D8 D9 S11 S12 S13 D10 D11 D12 S3 S4 S6 S10 H1 H2 C13 D2 D3 D4 H6 H3 D13 J1 J2 C1 C2 C3 C4 D1 S5 H5 H11 H12 C6 C7 C8 C9 S2 S8 S9 H10 D5 D6 D7 H4 H13 C5
题目题目描述Shuffling is a procedure used to randomize a deck of playing cards.Because standard shuffling techniques are seen as weak, and in order toavoid "inside jobs" where employees collaborate with g