00-自测5. Shuffling Machine
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.
#include<iostream>
#include<string>
using namespace std;
int main() {
int j;
int i;
int N;
int arr[];
string b[];
string a[] = { "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9",
"S10", "S11", "S12", "S13", "H1", "H2", "H3", "H4", "H5", "H6",
"H7", "H8", "H9", "H10", "H11", "H12", "H13", "C1", "C2", "C3",
"C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11", "C12", "C13",
"D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "D11",
"D12", "D13", "J1", "J2" };
cin >> N;
for (i = ; i < ; i++) {
cin >> arr[i];
}
for (j = ; j <= N; j++) {
for (i = ; i < ; i++)
b[arr[i] - ] = a[i];
for (i = ; i < ; i++)
a[i] = b[i];
}
for (i = ; i < ; i++) {
cout << a[i] << " ";
}
cout << a[] << endl;
return ;
}
00-自测5. Shuffling Machine的更多相关文章
- pat00-自测5. Shuffling Machine (20)
00-自测5. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Sh ...
- PAT自测-5 Shuffling Machine
原题连接https://pta.patest.cn/pta/test/17/exam/4/question/264 Shuffling is a procedure used to randomize ...
- 数据结构练习 00-自测5. Shuffling Machine (20)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 自测-5 Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- Shuffling Machine和双向链表
1. 双向链表 https://github.com/BodhiXing/Data_Structure 2. Shuffling Machine https://pta.patest.cn/pta/t ...
- 1042. Shuffling Machine (20) - sstream实现数字转字符串
题目例如以下: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffli ...
- PAT 1042. Shuffling Machine (20)
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- PAT1042:Shuffling Machine
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- A1042. Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
随机推荐
- HDU 6318 Swaps and Inversions(归并排序 || 树状数组)题解
题意:一个逆序对罚钱x元,现在给你交换的机会,每交换任意相邻两个数花钱y,问你最少付多少钱 思路:最近在补之前还没过的题,发现了这道多校的题.显然,交换相邻两个数逆序对必然会变化+1或者-1,那我们肯 ...
- jvm 内存溢出问题排查方法
如果你做TCP通讯或者map集合操作,并发处理等功能时,很容易出现 Java 内存溢出的问题.本篇文章,带领大家深入jvm,分析并找出jvm内存溢出的代码. jvm中除了程序计数器,其他的区域都有可能 ...
- python-ConfigParser模块【读写配置文件】
对python 读写配置文件的具体方案的介绍 1,函数介绍 import configParser 如果Configparser无效将导入的configParser 的C小写 1.1.读取配置文件 - ...
- _itemmod_strengthen_item
`enchant_id`升级后的附魔Id `prev_enchant_id` 上级附魔Id `description` 描述,出现在菜单中 `enchantReqId`升级附魔效果的消耗模板 `rem ...
- codeforces 768E Game of Stones
题目链接:http://codeforces.com/problemset/problem/768/E NIM游戏改版:对于任意一堆,拿掉某个次数最多只能一次. 对于一堆石头数量为$X$.找到一个最小 ...
- Error: Program type already present: okhttp3.Authenticator$1
在app中的build.gradle中加入如下代码, configurations { all*.exclude group: 'com.google.code.gson' all*.exclude ...
- python中字典的用法
一,字典的简单介绍概念: 字典(dict)是python中唯一的一个映射类型.他是以{ }括起来的键值对组成. 在dict中key是 唯一的. 在保存的时候, 根据key来计算出一个内存地址. 然后将 ...
- sqlserver 中常见的函数字符串函数
---字符中操作函数 UPPER(S) 将字符串统一为大写字母 SELECT UPPER('asasA') --ASASA LOWER(S) 将字符串统一为小写字母 SELECT LOWER('asa ...
- MySQL中的排序(ORDER BY)
当使用 SELECT FROM 时,如果不排 序,数据一般将以它在底层表中出现的顺序显示.这可以是数据最初添加到表中的顺序.但是,如果数据后来进行过更新或删除,则此顺 序将会受到MySQL重用回收存储 ...
- Qt网络应用开发初步
应用层的网络协议,如HTTP/FTP/SMTP等简称"应用协议",他们运行在TCP/UDP之上,从Qt5开始,已经不再分别提供QHttp类,QFtp类,应用层的编程使用QNet ...