ACM_Mystery
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的更多相关文章
随机推荐
- pressure coeffcient of a wing/blade
software: CFD POST ANSYS menu bar, select Tools > Macro Calculator. \ correction: Ref pressure is ...
- slf4j+log4j2的配置
昨天自己测试了一下slf4j+log4j2的配置,可以正常使用,虽然配置十分简单,但好记性不如烂笔头,想想还是记录下来吧. 运行的环境:jdk1.7.tomcat7.Maven的web项目 1.在新建 ...
- 【Codeforces 364A】Matrix
[链接] 我是链接,点我呀:) [题意] 让你求出b[i][j]=s[i]*s[j]规则构成的矩阵 的所有子矩阵中子矩阵的和为a的子矩阵的个数 [题解] (x,y,z,t) 会发现它的和就是sum(x ...
- Maven学习总结(30)——Maven项目通用三级版本号说明
项目版本号说明 当前版本号:1.0.0-SNAPSHOT 本项目采用通用的三级版本号,版本号格式是[主版本号].[副版本号].[修复版本号]-[稳定状态],如:1.0.0-SNAPS ...
- Java基础学习总结(83)——Java泛型总结
1. 什么是泛型? 泛型(Generic type 或者 generics)是对 Java 语言的类型系统的一种扩展,以支持创建可以按类型进行参数化的类.可以把类型参数看作是使用参数化类型时指定的类型 ...
- zoj 3768 Continuous Login
Pierre is recently obsessed with an online game. To encourage users to log in, this game will give u ...
- 后台获得集合,变成json字符串,放到EL表达式,js进行获取遍历
//把集合编程json字符串,放到el表达式 JSONArray array = new JSONArray(); JSONArray fromObject = array.fromObject(ar ...
- BAT经典面试题,深入理解Java内存模型JMM
Java 内存模型 Java 内存模型(JMM)是一种抽象的概念,并不真实存在,它描述了一组规则或规范,通过这组规范定义了程序中各个变量(包括实例字段.静态字段和构成数组对象的元素)的访问方式.试图屏 ...
- Oracle Multitenant Environment (一) About
About oracle mulittenant environment The multitenant architecture enables an Oracle database to func ...
- JAVA 如何反编译JAR文件
1 直接的jar文件可以用winrar解压,然后得到class文件,但是这里得到的class文件也是编译过的二进制文件,用传统的文本编辑器无法打开. 2 用XJad这个软件可以反编译Jar文件,直接找 ...