HDU 4492 Mystery (模拟)
来源:互联网 发布:数学建模书籍推荐知乎 编辑:程序博客网 时间:2024/05/21 19:37
Mystery
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 548 Accepted Submission(s): 275
Total Submission(s): 548 Accepted Submission(s): 275
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.
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
41MAC31 1 12IW2C0NP3OS 1RLDFA220 3 3 -3 7 -8 2 7 -4 3 8 7 4 1 1 -4 5 2 5 -6 -3 -43G.IETSNPRBU172 4 5 -6 -1 -3 -2 -4 -4 1 -1 5 -3 4 1 -2 44PIBN MRDSYEO16-4 4 -1 4 5 3 -5 4 -3 -3 -2 -5 -5 -3 1 3
Sample Output
1 ACM2 ICPC 2013 WORLD FINALS3 IN ST. PETERSBURG4 SPONSORED BY IBM
Source
Greater New York 2012
Recommend
liuyiding
题意:
题意:
给你一字符串和一些整数,这些整数表示相对于当前位置的位移,并输出该位所对应的字符。思路:
起始位置位于0。样例3是有一点问题的,因为输入中并没有空格。
1.直接按题意模拟
2.读入字符串时,建议使用fgets,不易发生内存越界,堆栈溢出等问题,较安全,因为它规定了数组长度。
3.输入时回车符最好别使用'\n',一开始就错这,可以使用getchar(),或者scanf(“%d%*c”,&num);
/*************************************************************************> File Name: 4492.cpp> Author: BSlin> Mail: > Created Time: 2013年10月06日 星期日 18时00分41秒 ************************************************************************/#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <algorithm>#include <iterator>#include <vector>#include <map>#include <set>#include <stack>#include <queue>#define MP make_pair#define INF (1<<30)#define PI acos(-1.0)#define esp 1e-8const int dx[4]={0,0,0,0};using namespace std;#define read freopen("in.txt","r",stdin)#define write freopen("out.txt","w",stdout)#if defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__)#define LL __int64#define LLS "%" "I" "6" "4" "d"#else#define LL long long#define LLS "%" "l" "l" "d"#endifint main(int argc, char** argv) { //read; int t,num,n,pos,len; char str[100]; int a[520]; scanf("%d",&t); while(t--) { scanf("%d",&num); //用getchar(),或%*c,别用\n getchar(); fgets(str,100,stdin); //fgets 挺好 len = strlen(str); len --; scanf("%d",&n); for(int i=0; i<n; i++) { scanf("%d",&a[i]); } pos = 0; printf("%d ",num); for(int i=0; i<n; i++) { pos = (pos + a[i] + len) % len; printf("%c",str[pos]); } printf("\n"); } return 0;}
- HDU 4492 Mystery (模拟)
- UVALive 6181|HDU 4492|Mystery|猜题意|模拟
- hdu 4492 Mystery
- hdu 4492 Mystery
- mystery
- hdu 3347(模拟)
- hdu 3344(模拟)
- hdu 2142 (模拟,,,)
- hdu 1034 (模拟)
- hdu 2526(模拟)
- hdu 2525(模拟)
- HDU EBCDIC(模拟)
- hdu 1571(模拟)
- HDU 5491(模拟)
- HDU 5499(模拟)
- hdu 5671(模拟)
- HDU 1266 (模拟)
- hdu 1029(模拟)
- js中parseInt()与parseFloat(),Number(),Boolean(),String()转换
- 实现摄氏温度和华氏温度的相互转换
- Qt学习笔记
- 于IIS 7的HTTP 错误 500.0 - Internal Server Error(错误代码:0x800700.
- 编程之美-数组分割
- HDU 4492 Mystery (模拟)
- 01 设计以 XNA 为基础的 Windows Phone 7 游戏
- 一个老程序员的建议
- 检查确认Sybase SQL Anywhere的license
- 关于Tomcat启动出现java.lang.ClassNotFoundException异常的解决方案
- 程序员求职之道(《程序员面试笔试宝典》)之如何回答算法设计问题?
- shell 变量的作用域
- Python学习之初学
- 通信网