pat00-自测5. Shuffling Machine (20)
00-自测5. Shuffling Machine (20)
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)的更多相关文章
- 数据结构练习 00-自测5. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- PAT 1042. Shuffling Machine (20)
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- A1042 Shuffling Machine (20)
1042 Shuffling Machine (20)(20 分) Shuffling is a procedure used to randomize a deck of playing cards ...
- PAT 甲级 1042 Shuffling Machine (20 分)(简单题)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
- PAT 1042 Shuffling Machine (20 分)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT自测-5 Shuffling Machine
原题连接https://pta.patest.cn/pta/test/17/exam/4/question/264 Shuffling is a procedure used to randomize ...
- 1042. Shuffling Machine (20) - sstream实现数字转字符串
题目例如以下: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffli ...
- 自测-5 Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
随机推荐
- NPOI 2.1.3.1导入Excel
引入NPOI 2.1.3.1的包 项目引入 using NPOI.XSSF.UserModel;using NPOI.SS.UserModel; 控制器方法: public ActionResult ...
- 八大排序算法的python实现(一)直接插入排序
刚参考网上的以及书上的资料把这八大算法又复习了一遍,感悟就是:有些算法原理真的很简单,一看就懂,但实现起来总是有这样那样的问题. 闲言少叙,先贴代码,之后再以自己的理解,以及自己在理解与实现的过程中遇 ...
- JavaBean的概念
Java的一个特性,数据与行为相分离.数据就是成员变量,行为就是setter和getter方法 JavaBean是Java中开发的可以跨平台的重要组件,在JSP中常用来封装业务逻辑和数据库操作.Jav ...
- 数组常用的API——splice()截取
他的几个作用:截取 删除 增加 替换. 当传递一个参数的时候 : 截取开始的位置,参数代表下标,默人会截取到结束的位置. 当传递两个参数的时候: 第一个参数是删除的下标: 第二个参数代表删除几个 ...
- Jenkins持续集成企业实战系列之Jenkins持续集成简介及安装-----02
1. Jenkins持续集成简介 注:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任. 最初接触Jenkins也是由于公司需求, ...
- php 面试常问问题
1.看看简历,会问一些过去做的项目的用户量.pv.吞吐量.相关难点和解决方法等2.数据库设计经验,为什么进行分表? 分库?一般多少数据量开始分表? 分库? 分库分表的目的? 什么是数据库垂直拆分? 水 ...
- SDUT OJ 图结构练习——最短路径 ( Floyed 算法 AND Dijkstra算法)
图结构练习——最短路径 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem ...
- sql 语句设置主键
创建表时候 SQL code? 1 2 3 4 CREATE TABLE tb ( id INT IDENTITY(1,1) PRIMARY KEY, ) 添加时候 SQL code? 1 2 ALT ...
- java 实现在线阅读 .pdf
1.资源的本地地址 2.设置响应头 3.代码实现 @ResponseBody @RequestMapping(value = "/read") @ApiOperation(valu ...
- java 开发原则(七个)
转自 : https://blog.csdn.net/u011288271/article/details/52497602 对于Java看到过一个很有意思的说法:Java有六大心法,23种武功招式. ...