Mystery
March 10, 2013
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char a[200];
int b[800];
int main(void){
#ifndef ONLINE_JUDGE
freopen("in", "r", stdin);
#endif
int t; scanf("%d", &t);
while (t--){
int s; scanf("%d", &s);
getchar();
gets(a);
int n; scanf("%d", &n);
for (int i = 0; i < n; ++i) scanf("%d", b+i);
printf("%d ", s);
int po = 0, len = strlen(a);
for (int i = 0; i < n; ++i) {
po = po + b[i];
if (po >= len) po = po % len;
else if (po < 0) po = (po + len);
printf("%c", a[po]);
}
printf("\n");
}
return 0;
}
题目不难,就是卡了很久,最后才发现,原来是输入的文件里面写错了,多打了一个空格……次奥……