1042 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
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-23-18.50.30
* Description : A1042
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
;
]={'S','H','C','D','J'};
],enda[N+],nexta[N+];
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
int K;
scanf("%d",&K);
;i<=N;i++){
sta[i]=i;
}
;i<=N;i++){
scanf("%d",&nexta[i]);
}
while(K--){
;i<=N;i++){
enda[nexta[i]]=sta[i];
}
;i<=N;i++){
sta[i]=enda[i];
}
}
;i<=N;i++){
) printf(" ");
sta[i]--;
printf(],sta[i]%+);
}
;
}
1042 Shuffling Machine (20 分)的更多相关文章
- 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 Advanced 1042 Shuffling Machine (20 分)(知识点:利用sstream进行转换int和string)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 1042 Shuffling Machine (20分)(水)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 【PAT甲级】1042 Shuffling Machine (20 分)
题意: 输入洗牌次数K(<=20),输入54张牌每次洗入的位置(不是交换的位置),输出洗好的牌. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC ...
- PAT 1042. Shuffling Machine (20)
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- 1042. Shuffling Machine (20) - sstream实现数字转字符串
题目例如以下: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffli ...
- 1042. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- PAT(A) 1042. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
随机推荐
- DevExpress v18.1新版亮点——WinForms篇(六)
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress WinForms v18.1 的新功能,快来下载试用新版本! ...
- <小常识>
1,DOS(磁盘操作系统) 2,人机交互: (1):图形化界面(Graphical User interface GUI), (2):命令行方式(Command Line Interface CLI) ...
- 《JAVA----day01和day02》
1,(在有符号的情况下)若一个二进制数都是1,则对应的十进制数是-1 2,在定义数值类型时,若无特别说明,整数默认:int 小数默认:double 在内存中 占字节数 取值范围 (1)byte:1个 ...
- 入门级:理解FAT32文件系统(转载翻译)
FAT(File Allocation Table ) 这个网页的目的是帮助你理解怎么样在微软FAT32文件系统下取得数据,处理的硬盘的大小通常在500M到几百G之间.FAT是一个相对简单和纯净的文件 ...
- 关于Oracle的一些基础知识以及注意事项
一.oracle基础 1.1 DDL(Data Definition Language) 数据定义语言 create drop,desc(注意,此操作只能在PL/SQL Developer的命令窗户执 ...
- 配置ssh互信的一个小问题记录
在我们安装集群软件时,经常需要配置机器之间的互信,每个人也有一套自己熟悉的方法. 但是在今天配置互信过程中,发现操作过程还是一样,但是就是不能互信,通过查找资料解决了,做一下记录. 我经常使用的方式: ...
- vue-cli 添加到生产环境问题总结
1. 路径问题 部署到生产环境后的实际链接为: 服务器项目路径 + serviceUrl的路径 创建 GlobalConstant.js 分别配置 开发环境和生产环境的 路径 (注:此处生 ...
- ARM裸板开发:07_IIC 通过IIC总线接口读写时钟芯片时间参数实现的总结
问题一:程序直接在iRAM内部可正常执行,而程序搬移(Nand ->SDRAM)之后,就不能正常运行了 #define NAND_SECTOR_SIZE 2048 /* 读函数 */ void ...
- MyEclipse2017CI破解教程
因为工作中需要有多个MyEclipse去管理不同的项目组的工作,恰逢MyEclipse2017CI发布,下载破解尝鲜,因为之前安装了MyEclipse2016CI7和MyEclipse2014GA,两 ...
- BZOJ4481: [Jsoi2015]非诚勿扰【概率期望+树状数组】
Description [故事背景] JYY赶上了互联网创业的大潮,为非常勿扰开发了最新的手机App实现单身 大龄青年之间的"速配".然而随着用户数量的增长,JYY发现现有速配的算 ...