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的更多相关文章
随机推荐
- 洛谷 1821 [USACO07FEB]银牛派对Silver Cow Party
[题解] 其实解法 #include<cstdio> #include<cstring> #include<algorithm> #define LL long l ...
- saltstack(二) master、minion常用配置选项
master常用配置选项: interface: 指定bind的地址(默认0.) publish_port:指定发布端口(默认4505) ret_port: 指定结果返回端口,与minion配置文件的 ...
- 邓_ HTML+CSS·经常使用的设计方法
:WPA;P:hejia,888?;S:Hejia666; https://github.com/qq1415551519 HTML+CSS·经常使用的设计方法: ================== ...
- MVC系统学习4—ModelMetaData
在Mvc R2中,新引入了一些扩展方法,如后面带一个for的方法,这些扩展方法会根据Model的属性自定生成相应的Html元素,如Html.EditFor(Model=>Model.IsAppr ...
- css & no margin & print pdf
css & no margin & print pdf no header & no footer https://stackoverflow.com/questions/46 ...
- 最接近的点配对(分治问题理解) && HDU 1007代码
题目大意: 给定一堆点集,在这一堆点集中找到一组点集它们之间的距离达到最短 对于HDU1007因为求圆的半径,所以距离还要除以2 普通情况下,可以将nge点,将任意两个点之间的距离都算一遍,在循环过程 ...
- validate针对checkbox、radio、select标签的验证
jQuery.validate 是jquery的一个插件,用来辅助开发者在客户端方便快捷的实现表单验证,最终达到提高用户体验的目的. 示例代码 <form id="formLogin& ...
- 在代码动态设置RelativeLayout的属性,比如layout_below
( (RelativeLayout.LayoutParams)holder.ivLvDivider.getLayoutParams()).addRule(RelativeLayout.BELOW, R ...
- 《Linux内核分析》MOOC课程
http://www.cnblogs.com/wickedpriest/p/4315189.html
- 推断client手机类型,并跳转到对应的app下载页面
实现的原理,是检測浏览器的 USER-AGENT 这个header,然后依据正則表達式来确定client类型. 假设都不匹配,Fallback回退策略是显示相应的页面.让用户自己选择. 适合採用二维码 ...