Fork me on GitHub

UVALive 6181

模拟题,注意细节。。

 

#include <iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#define mod 1073741824
using namespace std;

char a[100];
char res[1005];
int op[512];

int main()
{
    int t,n,i,k;
    scanf("%d",&t);
    int cs;
    int now;
    while(t--)
    {
        memset(op,0,sizeof(op));
        memset(a,0,sizeof(a));
        memset(res,0,sizeof(res));
        scanf("%d",&cs);
        getchar();
        gets(a);                //scanf("%s",a);
        
        scanf("%d",&n);
        for(i=0;i<n;i++)
            scanf("%d",&op[i]);
        k=0;
        int len=strlen(a);
        now=op[0];
        if(now<0)
            now+=len;
        else if(now>=len)
            now%=len;
        res[k++]=a[now];
        
        for(i=1;i<n;i++)  //op
        {
            now+=op[i];
            if(now>=len)
                now%=len;
            if(now<0)
                now+=len;
            res[k++]=a[now];
        }
        printf("%d %s\n",cs,res);
    }
    return 0;
}
View Code

 

posted @ 2013-12-13 13:25  whatbeg  阅读(210)  评论(0编辑  收藏  举报