PAT (Advanced Level) 1042. Shuffling Machine (20)
简单题。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
using namespace std; struct X
{
char c;
int num;
}s[]; int ans[],p[],tmp[];
int n; void init()
{
for(int i=;i<=;i++) s[i].c='S',s[i].num=i;
for(int i=;i<=;i++) s[i].c='H',s[i].num=i-;
for(int i=;i<=;i++) s[i].c='C',s[i].num=i-;
for(int i=;i<=;i++) s[i].c='D',s[i].num=i-;
s[].c='J'; s[].num=;
s[].c='J'; s[].num=;
} int main()
{
init();
for(int i=;i<=;i++) ans[i]=i; int k; scanf("%d",&k);
for(int i=;i<=;i++) scanf("%d",&p[i]); for(int i=;i<=k;i++)
{
for(int j=;j<=;j++) tmp[p[j]]=ans[j];
for(int j=;j<=;j++) ans[j]=tmp[j];
} for(int i=;i<=;i++)
{
printf("%c%d",s[ans[i]].c,s[ans[i]].num);
if(i<) printf(" ");
else printf("\n");
}
return ;
}
PAT (Advanced Level) 1042. Shuffling Machine (20)的更多相关文章
- PTA(Advanced Level)1042.Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
- 【PAT甲级】1042 Shuffling Machine (20 分)
题意: 输入洗牌次数K(<=20),输入54张牌每次洗入的位置(不是交换的位置),输出洗好的牌. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- PAT 1042. Shuffling Machine (20)
1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shu ...
- PAT 甲级 1042 Shuffling Machine (20 分)(简单题)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
- PAT 1042 Shuffling Machine (20 分)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- PAT Advanced 1042 Shuffling Machine (20 分)(知识点:利用sstream进行转换int和string)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
随机推荐
- leetcode21
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- STM32 一通道单次转换
之前弄过ADC连续转换,还配了DMA传输,项目上不希望这样做,因为有其他设备用到DMA传输,就会不停的抢占优先级,效率低. 按照需求改成ADC单次转换,非连续,用的时候只需调下函数执行一次转换即可. ...
- find the closest sum to a target value
problem: given an array of integers including positive and negative, a target value. find 2 numbers ...
- React和动态网站接口的经济学
来自: React and the economics of dynamic web interfaces 自从2000开始我就一直在做web开发,曾见过很多以各种库和框架的起起落落,这些库和框架作为 ...
- PHP上传文件详解
1.上传文件使用的提交方式和请求Content-type POST提交方式,原始的form表单提交请加上enctype="multipart/form-data" 2.MAX_FI ...
- UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-15: ordinal not in range(128)
python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报类似这样的错误. UnicodeEncodeError: 'ascii' codec can't ...
- PopUpManager弹出窗口
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...
- oracle数据库的数据类型
一.字符类型 (1)固定长度的字符串 CHAR(字节长度是1~2000之间) CHAR(8)可以存储4个双字节的字符,8个单字节的字符,不足8字节剩余的部分用空格占据 (2)可变长度字符串 VARCH ...
- spice-vdagent
The spice-vdagent should be running in the guest. Have you installed the spice guest tools in your w ...
- TP4056大电流1A使用注意事项
源:TP4056大电流1A使用注意事项 TP4056为南京拓微集成电路有限公司推出的锂电池充电产品系列中的大电流充电产品.具有最大电流1A,峰值电流1.1A,良好环境下甚至峰值1.2A的单节锂离子电池 ...