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的更多相关文章
随机推荐
- python3接口测试某个模块的很多接口有的用post有的用get
没啥好说的,啊哈哈 大神提示可以判断下用post还是get,但是加到哪里合适呢?仔细看认真看 耶耶耶
- 洛谷 2176 [USACO14FEB]路障Roadblock
[题意概述] 修改图中任一一条边的边权,使其加倍,问怎样使修改后图中的1~n的最短路最大.输出最短路的增量. [题解] 先跑一遍dijkstra求出1~n的路径长度,记录下经过的边.枚举这些边进行修改 ...
- java 生成20位唯一ID,生成不会重复的20位数字----https://blog.csdn.net/weixin_36751895/article/details/70331781
java 生成20位唯一ID,生成不会重复的20位数字----https://blog.csdn.net/weixin_36751895/article/details/70331781
- COJ 1351 Tree Counting 动态规划
题目大意是: 给定一个n,k,表示树上共有n个节点,每个节点最多有k个叶子,问一共多少种摆法,答案对1000000007取模 这里定义一个dp[i]表示 i 个节点对应有多少种方法 f[i][j] 表 ...
- BZOJ 1853
http://www.lydsy.com/JudgeOnline/problem.php?id=1853 岛娘在空间上发的题解就看了看果然被骗了.还以为是数位dp. 原来是容斥啊.好吧第一道正式的题目 ...
- 过河(codevs 1155)
题目描述 Description 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子上.由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥 ...
- HDU1914(稳定婚姻)
http://acm.hdu.edu.cn/showproblem.php?pid=1914 思路:Gale-Shapley算法.算法过程是男士不停地求婚,女士不停地拒绝.在每一轮中,每个尚未订婚的男 ...
- 将完整的Maven远程存储库下载到本地存储库(别试了,不太可取)
别试了,这种方式不太可取. 要解决可以有如下思路: 1.做成镜像站点,有如下命令: wget -m http://site.to.mirror.com #-m代表“镜子”. rsync repo1.m ...
- laravel5.5更新到laravel5.7
为什么要更新呢?因为项目用的第三方后台扩展包,有很些bug,不够完美.想要一个漂亮的后台,那个后台只支持5.7. 然后,我就开始更新框架了. 修改后:"php": "&g ...
- VFL演示样例
上篇文章向大家介绍了VFL的基本的语法点,假设对下面演示样例不熟的童鞋,能够前去參考.废话不多说.我们直接来看演示样例. 演示样例一 将五个大小同样.颜色不同的view排成一行,view间的间隔为15 ...