Mystery

Time Limit: 2000/1000ms (Java/Others)

Problem Description:

No Description

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
解题思路:简单模拟一下n次访问字符串中的字符,如果访问的下标(每次将x叠加)小于0,要加上第二行字符串的长度len,再取余len输出当前被访问的字符即可(第三组测试样例应该是错的),水过!
AC代码:
 #include<bits/stdc++.h>
using namespace std;
int main(){
int p,d,n,x,j,k,len;char ch[],str[];cin>>p;
while(p--){
cin>>d;getchar();gets(ch);
j=k=;len=strlen(ch);memset(str,'\0',sizeof(str));
cin>>n;
while(n--){
cin>>x;k+=x;
if(k<)k+=len;
str[j++]=ch[k%len];
}
cout<<d<<' '<<str<<endl;
}
return ;
}

ACM_Mystery的更多相关文章

随机推荐

  1. CF441D

    题目大意 给出一个有n个数的序列 求符合 区间各数或起来的数大于区间最大数 的区间的个数 题解 预处理出每个数每一位是0的那位左边最近的1和右边最近的1,用单调栈找出每个最大值所在的区间的左右端点,统 ...

  2. The Falling Leaves(建树方法)

    uva 699 紫书P159 Each year, fall in the North Central region is accompanied by the brilliant colors of ...

  3. HDU 5291 Candy Distribution

    Candy Distribution Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  4. Leetcode 114.二叉树展开为链表

    二叉树展开为链表 给定一个二叉树,原地将它展开为链表. 例如,给定二叉树 将其展开为: class Solution{ public: void flatten(TreeNode* root){ if ...

  5. HDU 1325 拓扑排序

    根据题目所给的3个不符合情况的条件,一个个判断图是否符合这3个条件即可 1.不能出现内部环,拓扑排序判断 2.不能有超过1个点的入度为0,因为只有一个树根 3.每个点最多一个入度 这里要注意的一点是这 ...

  6. [luoguP2854] [USACO06DEC]牛的过山车Cow Roller Coaster(DP + sort)

    传送门 先按照起点 sort 一遍. 这样每一个点的只由前面的点决定. f[i][j] 表示终点为 i,花费 j 的最优解 状态转移就是一个01背包. ——代码 #include <cstdio ...

  7. [K/3Cloud] 首页增加一个自定义页签及页面内容

    在K3Cloud登录后的门户首页增加一个页签,如增加一个[BBS论坛] 2013-7-30 11:18:51 上传 下载附件 (84.81 KB)  增加页签 可以这么来做: 进入BOS IDE ,找 ...

  8. HXY烧情侣(洛谷 2194)

    题目描述 众所周知,HXY已经加入了FFF团.现在她要开始喜(sang)闻(xin)乐(bing)见(kuang)地烧情侣了.这里有n座电影院,n对情侣分别在每座电影院里,然后电影院里都有汽油,但是要 ...

  9. 武大OJ 612. Catch the sheep

    Description Old Sama is a great and powerful magician in the word. One day, a little girl, Anny, tou ...

  10. SpringMvc切面校验JavaBean及基础类型

    先配置好aop需要的配置,文:https://www.cnblogs.com/jiangxishicheng/p/10896498.html 编写校验切面类: package com.aspect;/ ...