- 1.大赛题目
- 2.中文翻译
- 3.代码案例
- 4.解题思路
- 4.1代码举例
Shuffle Card Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 6695 Accepted Submission(s): 2061
Problem Description A deck of card consists of n cards. Each card is different, numbered from 1 to n. At first, the cards were ordered from 1 to n. We complete the shuffle process in the following way, In each operation, we will draw a card and put it in the position of the first card, and repeat this operation for m times.
Please output the order of cards after m operations.
Input The first line of input contains two positive integers n and m.(1= 0; i--) { if(Ex[B[i]]==0) { out[count++] = B[i]; //这里Ex[B[i]]等于几都可以,只要不等于0 Ex[B[i]] = 1; } }
Ex[3] = 0->out[1] = 3->Ex[3] = 1 Ex[4] = 0->out[2] = 4->Ex[4] = 1 Ex[3] = 1 ->结束循环
for(int i = 0;iout[3] = 1 Ex[2] = 0->out[4] = 2 Ex[3] = 1 Ex[4] = 1 Ex[5] = 0->out[5] = 5