00-自测5. Shuffling Machine (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue

Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in 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 of 54 cards according to a given random order and repeats for a given number of times. It is assumed that the initial status of a card deck is in the 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 the number at the 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}, the result will be: J2, H5, D13, S3, C1. If we are to repeat the shuffling again, the result will be: C1, H5, S3, J2, D13.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer K (<= 20) which is the number of repeat times. Then the next line contains the given order. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print the shuffling results in one line. All the cards are separated by a space, and there must be no extra space at the end of the line.

Sample Input:

2
36 52 37 38 3 39 40 53 54 41 11 12 13 42 43 44 2 4 23 24 25 26 27 6 7 8 48 49 50 51 9 10 14 15 16 5 17 18 19 1 20 21 22 28 29 30 31 32 33 34 35 45 46 47

Sample Output:

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

提交代码

 #include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <iostream>
using namespace std;
char f[]={'S','H','C','D','J'};
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int time;
scanf("%d",&time);
int card1[],card2[],i,j;
for(i=;i<=;i++){
card1[i]=i;
}
int order[];
for(i=;i<=;i++){
scanf("%d",&order[i]);
}
for(i=;i<=time;i++){
for(j=;j<=;j++){
card2[order[j]]=card1[j];
}
for(j=;j<=;j++){
card1[j]=card2[j];
}
}
printf("%c%d",f[(card1[]-)/],card1[]%==?:card1[]%);
for(i=;i<=;i++){
printf(" %c%d",f[(card1[i]-)/],card1[i]%==?:card1[i]%);
}
printf("\n");
return ;
}

pat00-自测5. Shuffling Machine (20)的更多相关文章

  1. 数据结构练习 00-自测5. Shuffling Machine (20)

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

  2. PAT 1042. Shuffling Machine (20)

    1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...

  3. A1042 Shuffling Machine (20)

    1042 Shuffling Machine (20)(20 分) Shuffling is a procedure used to randomize a deck of playing cards ...

  4. PAT 甲级 1042 Shuffling Machine (20 分)(简单题)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  5. PAT 1042 Shuffling Machine (20 分)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  6. PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...

  7. PAT自测-5 Shuffling Machine

    原题连接https://pta.patest.cn/pta/test/17/exam/4/question/264 Shuffling is a procedure used to randomize ...

  8. 1042. Shuffling Machine (20) - sstream实现数字转字符串

    题目例如以下: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffli ...

  9. 自测-5 Shuffling Machine

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

随机推荐

  1. Go语言最佳实践——面向对象

    对于接口,应使用组合而非继承的方式扩展: 对于结构体,应定义独立的结构体,而非用嵌套模拟继承. 值接收者和指针接收者: 1.对于不可变类型创建只接受值接收者的方法,而为可变的类型创建接受指针接收者的方 ...

  2. 洛谷P4557 [JSOI2018]战争(闵可夫斯基和+凸包)

    题面 传送门 题解 看出这是个闵可夫斯基和了然而我当初因为见到这词汇是在\(shadowice\)巨巨的\(Ynoi\)题解里所以压根没敢学-- 首先您需要知道这个 首先如果有一个向量\(w\)使得\ ...

  3. [转]Resolving Python error: Unable to find vcvarsall.bat

    Resolving Python error: Unable to find vcvarsall.bat While installing python package flask-user usin ...

  4. 自动判断PC端、手机端跳往不同的域名JS实现代码

    输入相同域名,在pc端和移动端会出现不同的页面效果,一种是用栅格系统实现自适应, 更多的是设计两套不同的模板和两个二级域名或者一个主域名和一个二级域名(就是有区别就可以了); js代码判断浏览器的用户 ...

  5. Sql server if-else以及switch

    --相当于C#中的if-else 根据levle列的值来判断自定义列显示的内容--要求then后面的数据类型必须一致 select * ,头衔=case when [levle]=1 then '菜鸟 ...

  6. Nginx+certbot 实现泛域名的https证书

    yum -y install git git clone  https://github.com/certbot/certbot cd certbot ./certbot-auto certonly ...

  7. java 中的Debug eclipse 开发工具使用

    Eclipse的debug模式:代码调试 * Eclipse或MyEclipse就是java的开发工具 * Eclipse开源的.免费的Java开发工具 * MyEclipse基于Eclipse开发出 ...

  8. Call requires API level 11 (current min is 8)报错

    新建一个Android Application Project,其中MainActivity.java中报错如下 Call requires API level 11(current min is 8 ...

  9. 洛谷 P1155 【NOIP2008】双栈排序

    题目链接 题解 这题有点神啊.. 我们仔细观察一下,发现两个栈内元素必须为降序 那么有结论 如果有\(i < j < k\) 且 \(a[k] < a[i] < a[j]\)则 ...

  10. 【贪心】洛谷 P1199 三国游戏 题解

     这个题尽管题目长,主要还是证明贪心的正确性(与博弈关系不大) 题目描述 小涵很喜欢电脑游戏,这些天他正在玩一个叫做<三国>的游戏. 在游戏中,小涵和计算机各执一方,组建各自的军队进行对战 ...