自己思路,没通过

#include <cstdio>
#define N 54
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
int start[N + 1] = {0}, end[N + 1] = {0}, sequence[N + 1] = {0};
for(int i = 1; i < N + 1; i++) {//初始化牌的编号
start[i] = i+1;
}
int n;
scanf("%d", &n);//输入操作的次数
for(int i = 1; i < N + 1; i++) {//输入每个位置上的牌在操作后的位置
int n;
scanf("%d", &sequence[i]);
}
/*for(int i = 1; i < N; i++) {
printf("%d\n", sequence[i]);
}*/
for(int i = 0; i < n; i++) {//执行n次操作
for(int i = 1; i < N + 1; i++) {
end[sequence[i]] = start[i];
}
for(int i = 1; i < N + 1; i++) {
start[i] = end[i];
}
}
/*for(int i = 1; i < N + 1; i++) {
printf("%d\n", end[i]);
}
*/
for(int i = 1; i < N; i++) {
//printf("%d---", end[i]);
if(i != N) {
if(end[i] / 13 == 0) {
if(end[i] % 13 == 0) {
printf("S13 ");
} else {
printf("S%d ", end[i] % 13);
}
} else if(end[i] / 13 == 1) {
if(end[i] % 13 == 0) {
printf("H13 ");
} else {
printf("H%d ", end[i] % 13);
}
} else if(end[i] / 13 == 2) {
if(end[i] % 13 == 0) {
printf("C13 ");
} else {
printf("C%d ", end[i] % 13);
}
} else if(end[i] / 13 == 3) {
if(end[i] % 13 == 0) {
printf("D13 ");
} else {
printf("D%d ", end[i] % 13);
}
} else if(end[i] / 13 == 4) {
printf("J%d ", end[i] % 13);
}
} else {
if(end[i] / 13 == 0) {
if(end[i] % 13 == 0) {
printf("S13");
} else {
printf("S%d", end[i] % 13);
}
} else if(end[i] / 13 == 1) {
if(end[i] % 13 == 0) {
printf("H13");
} else {
printf("H%d", end[i] % 13);
}
} else if(end[i] / 13 == 2) {
if(end[i] % 13 == 0) {
printf("C13");
} else {
printf("C%d", end[i] % 13);
}
} else if(end[i] / 13 == 3) {
if(end[i] % 13 == 0) {
printf("D13");
} else {
printf("D%d", end[i] % 13);
}
} else if(end[i] / 13 == 4) {
printf("J%d", end[i] % 13);
}
}
}
return 0;
}

AC

#include <cstdio>
const int N = 54;
char mp[5] = {'S', 'H', 'C', 'D', 'J'};
int start[N+1], end[N+1], next[N+1]; int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
int K;
scanf("%d", &K);
for(int i = 1; i <= N; i++) {
start[i] = i;
}
for(int i = 1; i <= N; i++) {
scanf("%d", &next[i]);
}
for(int step = 0; step < K; step++) {
for(int i = 1; i <= N; i++) {
end[next[i]] = start[i];
}
for(int i = 1; i <= N; i++) {
start[i] = end[i];
}
}
for(int i = 1; i <= N; i++) {
if(i != 1) printf(" ");
start[i]--;
printf("%c%d", mp[start[i] / 13], start[i] % 13 + 2);
}
return 0;
}

PAT A1042 Shuffling Machine的更多相关文章

  1. PAT甲级——A1042 Shuffling Machine

    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

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

  4. PAT 1042 Shuffling Machine[难]

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

  5. A1042 Shuffling Machine (20)

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

  6. pat 1042 Shuffling Machine(20 分)

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

  7. PAT 1042 Shuffling Machine (20 分)

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

  8. PAT 1042 Shuffling Machine

    #include <cstdio> #include <cstdlib> #include <vector> using namespace std; ] = {' ...

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

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

随机推荐

  1. 两个字说清楚编程语言实质-Python基础前传(3)

    大家都知道Python对于数据分析而言,意义重大.但对于运用Python来做数据分析的我们来说,学习一门编程语言,却有不小的难度:首先大部分伙伴不是计算机相关专业的科班出身,其次我们基本上也都没有程序 ...

  2. 转载一篇比较详细的讲解html,css的一篇文章,很长

      转载自这里,转载请注明出处. DIV+CSS系统学习笔记回顾   第一部分 HTML 第一章 职业规划和前景 职业方向规划定位: web前端开发工程师 web网站架构师 自己创业 转岗管理或其他 ...

  3. $\LaTeX$数学公式大全

    $\LaTeX$数学公式大全$1\ Geek\ and\ Hebrew\ letters$ $\LaTeX$数学公式大全$2\ Math\ Constructs$ $\LaTeX$数学公式大全$3\ ...

  4. vuecli3.0 webpack4 配置vuex

    废话不说,直接写步骤 1. npm install vux --save 2. npm install less less-loader --save-dev 3. npm install @vux/ ...

  5. Java如何接收前端传来的多层嵌套的复杂json串

    想看问题直接解决方式,直接拉到博文底部. Spring的controller在接收前端传参的时候如果参数使用@RequestBody标注的时候 @RequestBody 则会把前端参数转为JSON的形 ...

  6. openapi and light-4j

    light-4j项目支持openapi规范,本文介绍一下参照相关demo做的上传功能. openapi.yaml,按照规范编写内容,/openapi/swagger可以查看对应的swagger页面,A ...

  7. linux内核中有哪些子系统(框架)呢?

    注意: 分析用的linux内核版本为5.1.3 1. RTC子系统 2. Remote Processor子系统 3. Remote Processor Message子系统 4. SCSI子系统 5 ...

  8. CentOS7 源码安装 PostgreSQL 12

    PostgreSQL 12 源码安装 Table of Contents 1. 下载 2. 准备环境 3. 编译安装 4. 设置环境变量 5. 初始化数据库 6. 配置参数文件 6.1. postgr ...

  9. SmartTest__自动随机填充表单数据

    下载地址https://addons.mozilla.org/zh-CN/firefox/addon/smarttesttool/ 安装完成后可以在工具栏看见 目前只包含两个功能 测试使用

  10. Centos7下使用Ceph-deploy快速部署Ceph分布式存储-操作记录(转)

    之前已详细介绍了Ceph分布式存储基础知识,下面简单记录下Centos7使用Ceph-deploy快速部署Ceph环境:1)基本环境 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...