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的更多相关文章

  1. pat00-自测5. Shuffling Machine (20)

    00-自测5. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Sh ...

  2. PAT自测-5 Shuffling Machine

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

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

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

  4. 自测-5 Shuffling Machine

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

  5. Shuffling Machine和双向链表

    1. 双向链表 https://github.com/BodhiXing/Data_Structure 2. Shuffling Machine https://pta.patest.cn/pta/t ...

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

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

  7. PAT 1042. Shuffling Machine (20)

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

  8. PAT1042:Shuffling Machine

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

  9. A1042. Shuffling Machine

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

随机推荐

  1. POJ 1873 The Fortified Forest(凸包)题解

    题意:二维平面有一堆点,每个点有价值v和删掉这个点能得到的长度l,问你删掉最少的价值能把剩余点围起来,价值一样求删掉的点最少 思路:n<=15,那么直接遍历2^15,判断每种情况.这里要优化一下 ...

  2. 分布式事务框架&解决方案参考

    两种开源解决方案框架介绍: https://blog.csdn.net/zyndev/article/details/79604395#_97 LCN: https://www.jianshu.com ...

  3. 【Finchley】【升级变更】Spring Cloud 升级到Finchley版本后需要注意的地方

    Spring Boot 2.x 已经发布了很久,现在 Spring Cloud 也发布了 基于 Spring Boot 2.x 的 Finchley 版本,现在一起为项目做一次整体框架升级. 升级前 ...

  4. P4238 【模板】多项式求逆

    思路 多项式求逆就是对于一个多项式\(A(x)\),求一个多项式\(B(x)\),使得\(A(x)B(x) \equiv 1 \ (mod x^n)\) 假设现在多项式只有一项,显然\(B(x)\)的 ...

  5. SAP固定资产业务场景及方案

    SAP固定资产业务场景及方案 http://mp.weixin.qq.com/s/hYlaNHJMQBTZpyFAmP2h3A 对于FICO应用资深专家或顾问,须业务场景及需求成竹在胸:对于非财务顾问 ...

  6. C#——LINQ语句

    委托: //delegate 返回值 委托名(参数); //委托不能在方法中定义 ////实例化委托,并赋值 //委托名 实例名 = new 委托名(函数名).lambda表达式; //使用委托实例, ...

  7. 使用openlayers 3 在线加载天地图及GeoServer发布的地图

    使用openlayers3来加载天地图卫星图和标注图层,GeoServer发布地图,一并用openlayers测试加载出来,顺便实现了7种地图控件.下面直接贴代码: <!DOCTYPE html ...

  8. _spellmod_aura_trigger

    一.spell.dbc做一个空光环 二.配置_spellmod_aura_trigger表 comment 备注 aura 光环ID,有此光环时,才会触发下面技能 linkSpell1-3 链接的技能 ...

  9. FZU oj 2277 Change 树状数组+dfs序

    Problem 2277 Change Time Limit: 2000 mSec    Memory Limit : 262144 KB  Problem Description There is ...

  10. Centos7安装JDK8以及环境配置

    下载,选择centos7 64位版本 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.h ...