PAT A1042

#include <cstdio>
const int N = 54;
char Color[5] = {'S', 'H', 'C', 'D', 'J'};
int start[N+1], trans[N+1], end[N+1];
int main() {
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= N; i++){
        start[i] = i;
    }
    for(int i = 1; i <= N; i++){
        scanf("%d",&trans[i]);
    }
    for(int step = 0; step < n; step++){
        for(int i = 1; i <= N; i++){
            end[trans[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",Color[start[i]/13],start[i]%13+1);
    }
    return 0;
}

//36 52 37 38 3 39 40 53 54 41 11 12 13 42 43 44 2 4 23 24 25 26 27 6 7 8 48 49 50 51 9 10 14 15 16 5 17 18 19 1 20 21 22 28 29 30 31 32 33 34 35 45 46 47

 

上一篇:HIHOcoder 1466 后缀自动机六·重复旋律9


下一篇:Codechef PALPROB Palindromeness 回文树