HDU4492 UVALive6181 Mystery【水题】

Mystery

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 830 Accepted Submission(s): 449

Input
The first line of input contains a single integer P, (1 <= P <= 1000), which is the number of data sets that follow. Each data set consists of several lines. Each data set should be processed identically and independently.

The first line of each data set contains an integer D which is the data set number. The second line contains no more than the 93 distinct printable ASCII characters. The third line contains an integer, N (1 <= N <=512 ), which is the number of integers on the next (fourth) line of the dataset. Each integer on the fourth line is in the range -X to X where X is the number of characters on the second line minus 1.

Output
For each data set there is one correct line of output. It contains the data set number (D) followed by a single space, followed by a string of length N made of the characters on the second line of the input data set.

Sample Input
4
1
MAC
3
1 1 1
2
IW2C0NP3OS 1RLDFA
22
0 3 3 -3 7 -8 2 7 -4 3 8 7 4 1 1 -4 5 2 5 -6 -3 -4
3
G.IETSNPRBU
17
2 4 5 -6 -1 -3 -2 -4 -4 1 -1 5 -3 4 1 -2 4
4
PIBN MRDSYEO
16
-4 4 -1 4 5 3 -5 4 -3 -3 -2 -5 -5 -3 1 3

Sample Output
1 ACM
2 ICPC 2013 WORLD FINALS
3 IN ST. PETERSBURG
4 SPONSORED BY IBM

Source
Greater New York 2012

问题链接HDU4492 UVALive6181 Mystery
问题简述:(略)
问题分析
    水题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C语言程序如下:

/* HDU4492 UVALive6181 Mystery */

#include <stdio.h>
#include <string.h>

#define N 93
char s[N + 1];

int main(void)
{
    int p, d, n, x, len, i;
    scanf("%d", &p);
    while(p--) {
        scanf("%d%*c", &d);
        gets(s);
        len = strlen(s);
        scanf("%d", &n);

        printf("%d ", d);
        int tmp = 0;
        for(i = 1; i <= n; i++) {
            scanf("%d", &x);
            tmp += x;
            tmp = (tmp + len) % len;
            putchar(s[tmp]);
        }
        putchar('\n');
    }

    return 0;
}

posted on 2019-01-07 22:09  新海岛Blog  阅读(68)  评论(0)    收藏  举报

导航

// ... runAll: function() { this.resetPreCode(); hljs.initHighlightingOnLoad(); // 重新渲染,添加语法高亮 hljs.initLineNumbersOnLoad(); // 为代码加上行号 } // ...