zoukankan      html  css  js  c++  java
  • Mystery

    Mystery
    Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB
    Total submit users: 19, Accepted users: 18
    Problem 12606 : No special judgement
    Problem 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 


    Sample Input
    7 
    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 
    5
    D^obV@k"W*B&#]4!NcF$'lj%(d6XG5fi<Hxz7)2Lt~=8aQuvh}r_m+C9eI`-.>EwYyngZRsJKpqO{[\U|MPS,;T?031/A 
    93
    -1 11 44 39 -31 -44 10 5 24 14 1 -33 42 28 -34 7 -37 24 14 3 -7 18 4 19 37 4 20 2 41 -42 18 15 -3 10
    7 12 -11 -41 14 8 31 -26 37 -19 -17 -9 -16 15 31 14 29 -22 1 -24 20 -30 6 1 16 -29 31 -30 6 17 -43 -
    10 7 7 4 -22 10 -2 15 13 14 2 6 -17 34 -27 28 29 -28 2 33 -13 -15 6 -31 24 41 29 26
    6
    I
    1
    0
    7
    I
    13
    0 0 0 0 0 0 0 0 0 0 0 0 0
    
    Sample Output
    1 ACM
    2 ICPC 2013 WORLD FINALS
    3 INST. PETERSBURG
    4 SPONSORED BY IBM
    5 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz~'!@#$%^&*()_+-={}[]\|'";/.,<>?
    6 I
    7 IIIIIIIIIIIII
     1 #include <cstdio>
     2 #include <cstring>
     3 #include <cmath>
     4 using namespace std;
     5 char a[200];
     6 int b[800];
     7 int main(void){
     8 #ifndef ONLINE_JUDGE
     9   freopen("in", "r", stdin);
    10 #endif
    11   int t; scanf("%d", &t);
    12   while (t--){
    13     int s; scanf("%d", &s);
    14     getchar();
    15     gets(a);
    16     int n; scanf("%d", &n);
    17     for (int i = 0; i < n; ++i) scanf("%d", b+i);
    18     printf("%d ", s);
    19     int po = 0, len = strlen(a);
    20     for (int i = 0; i < n; ++i) {
    21       po = po + b[i];
    22       if (po >= len) po = po % len;
    23       else if (po < 0) po = (po + len);
    24       printf("%c", a[po]);
    25     }
    26     printf("\n");
    27   }
    28 
    29   return 0;
    30 }

    题目不难,就是卡了很久,最后才发现,原来是输入的文件里面写错了,多打了一个空格……次奥……

  • 相关阅读:
    Qt自定义一个事件类型
    Qt正则表达式限制输入
    QtQuick随笔
    右值引用示例
    虚函数习题复习
    实现基于IOCP的回声服务器端
    以纯重叠I/O方式实现回声服务器端(windows)
    使用事件对象(重叠I/O)
    pipe mmap
    ubuntu下压缩和解压缩的命令用法
  • 原文地址:https://www.cnblogs.com/liuxueyang/p/2952783.html
Copyright © 2011-2022 走看看