zoukankan      html  css  js  c++  java
  • 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代码:
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     int p,d,n,x,j,k,len;char ch[95],str[550];cin>>p;
     5     while(p--){
     6         cin>>d;getchar();gets(ch);
     7         j=k=0;len=strlen(ch);memset(str,'',sizeof(str));
     8         cin>>n;
     9         while(n--){
    10             cin>>x;k+=x;
    11             if(k<0)k+=len;
    12             str[j++]=ch[k%len];
    13         }
    14         cout<<d<<' '<<str<<endl;
    15     }
    16     return 0;
    17 }
  • 相关阅读:
    [ZJOI2006]书架
    luogu P3369 【模板】普通平衡树(splay)
    MegaCli是一款管理维护硬件RAID软件,可以通过它来了解当前raid卡的所有信息,包括 raid卡的型号,raid的阵列类型,raid 上各磁盘状态
    ipmi配置方法-20200328
    debian配置---->/etc/apt/sources.list apt基本源设置指南
    Alien 魔法:RPM 和 DEB 互转
    Debian 9 中设置网络
    SSH自动断开连接的原因-20200323
    mpstat命令
    dstat命令
  • 原文地址:https://www.cnblogs.com/acgoto/p/9236251.html
Copyright © 2011-2022 走看看