自己思路,没通过

#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. vue项目更换目录后执行npm run dev 就报错(新手进)

    在我们搭建好一个VUE项目的环境后,觉得这个项目存放的位置不好,想移动一下,但是移动后我们发现执行npm run dev就会报下面的错误: 明明只是移动了一下位置,就报错,实在是太恶心了. 但是只要我 ...

  2. [Vue] : Vue概述

    什么是Vue.js Vue.js 是目前最火的一个前端框架,React是最流行的一个前端框架. Vue.js 是前端的主流框架之一,和Angular.js.React.js 一起,并成为前端三大主流框 ...

  3. Android学习_MVC与Adapter

    一.           MVC模式 MVC模式代表Model-View-Controller(模型-视图-控制器)模式.这种模式用于应用程序的分层开发. Model(模型):代表一个存取数据的对象或 ...

  4. 在CUDA8.0下指定位置编译安装OpenCV3.1.0来实现GPU加速(Compiling OpenCV3.1.0 with CUDA8.0 support)

    在CUDA8.0下指定位置编译安装OpenCV3.1.0 一.本人电脑配置:ubuntu 14.04, NVIDIA GTX1060. 二.编译OpenCV3.1.0前,读者需要成功安装CUDA8.0 ...

  5. solr系列之solr-5.5.5 window单机版jdk-1.7 tomcat8安装

    一.Solr5.5.5.Tomcat8-x64.jdk-1.7-64单机部署 1.准备安装包,下载solr和tomcat的安装,直接解压即可(上篇一提供solr的下载路径) 2.在Solr5之前都还存 ...

  6. 14.链表中倒数第k个结点 Java

    题目描述 输入一个链表,输出该链表中倒数第k个结点. 思路 快指针和慢指针,快指针先跑K个单位然后慢指针开始跑,快指针跑到最后一个节点的时候慢指针对应的就是链表中倒数第k个结点 public stat ...

  7. LeetCode347——优先队列解决查询前k高频率数字问题

    给定一个非空的整数数组,返回其中出现频率前 k 高的元素. 例如, 给定数组 [1,1,1,2,2,3] , 和 k = 2,返回 [1,2]. 注意: 你可以假设给定的 k 总是合理的,1 ≤ k ...

  8. Repeater, DataList, 和GridView的区别及使用

    从对象层次图可以看出,Repeater是最轻最小的控件,它仅仅继承了基本控件的功能,包括ID属性.子控件集合等.另一方面,DataList和DataGrid则继承了WebControl功能,包括样式和 ...

  9. Linux shell利用sed如何批量更改文件名详解[转载]

     需求背景: 目录A用来存放自动化的包生成的apk文件,现在开发修改了包名的 命名规则:环境名称(pro|uat)-release-日期-v版本号.apk 原来的是思路是通过正则表达式匹配新的包名,但 ...

  10. 机器学习之DBSCAN聚类算法

    可以看该博客:https://www.cnblogs.com/aijianiula/p/4339960.html 1.知识点 """ 基本概念: 1.核心对象:某个点的密 ...