自己思路,没通过

#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. 微信打开手机内置浏览器跳转手机默认浏览器打开html网页

    微信上进行的网页宣传.游戏传播.APP下载各类活动很多,但是各位朋友肯定经常会遇到一些特殊需求,网页需要在手机默认浏览器打开而不是微信内置浏览器.这个问题怎么解决呢? 斗在微信营销的浪潮中 解决方案: ...

  2. [Linux]awk RSTART,RLENGTH

    转自 http://blog.sina.com.cn/s/blog_6d76c7e20102v381.html awk 是一门非常优秀的文本处理工具,甚至可以上升作为一门程序设计语言. 它处理文本的速 ...

  3. CF985C

    CF985C 题意: 你要组成N个木桶,组成每个木桶需要K个木块,(第二行给你N*K个木块),使得任意两个木桶之间的差值不超过L的情况,使得所有木桶可以装的水的和最大,输出这个最大和,如果无法满足要求 ...

  4. [NOIP2018]:旅行(数据加强版)(基环树+搜索+乱搞)

    题目描述 小$Y$是一个爱好旅行的$OIer$.她来到$X$国,打算将各个城市都玩一遍.小$Y$了解到,$X$国的$n$个城市之间有$m$条双向道路.每条双向道路连接两个城市.不存在两条连接同一对城市 ...

  5. PySpider的安装

    使用 Pip 安装,命令如下 pip install pyspider 命令执行完毕即可安装成功. 常见错误: Windows 下可能会出现这样的错误提示:Command "python s ...

  6. 计算可迭代对象的shape 老是忘~方便记法

    import numpy as np bbox =[ [[6.37532410e+02,3.83636505e+02,7.04683777e+02,4.43150146e+02, 6.23311400 ...

  7. Spring Boot ERROR StatusLogger No Log4j 2 configuration file found

    1. 问题描述 项目之前的 log4j2 配置没问题,把 pom 文件中的 spring-boot-starter-web 依赖删除后,然后启动项目就报错找不到 log4j2.yml 文件. 之前引用 ...

  8. substring(x)和substring(x,y)的用法

    substring(x)和substring(x,y)的用法 代码: public class textmu { /** * @param args */ public static void mai ...

  9. nginx 实现高并发和高负载

    一.Nginx是如何实现高并发的 service nginx start之后,然后输入#ps -ef|grep nginx,会发现Nginx有一个master进程和若干个worker进程,这些work ...

  10. Q窗口操作函数(窗口最大化,全屏,隐藏最大化最小化按钮)

    //Qt主窗口没有最小化,最大化按钮且最大化显示  int main(int argc, char *argv[]) { QApplication a(argc, argv); TestQtForWi ...