HDU4492:Mystery

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
 


 

累加确定位置,然后输出就是了

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

int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int t;
        scanf("%d%*c",&t);
        printf("%d ",t);
        char str[10000];
        gets(str);
        int i,len = strlen(str);
        char c;
        int tem = 0,k,a;
        scanf("%d",&k);
        for(i = 0; i<k; i++)
        {
            scanf("%d",&a);
            tem+=a;
            tem = (tem+len)%len;
            printf("%c",str[tem]);

        }
        puts("");
    }
    return 0;
}


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值