{"trustable":false,"sections":[{"title":"","value":{"format":"PLAIN","content":"Some message encoding schemes require that an encoded message be sent in two parts. The first part,called the header, contains the characters of the message. The second part contains a pattern that represents the message. You must write a program that can decode messages under such a scheme.\n\nThe heart of the encoding scheme for your program is a sequence of \\key\" strings of 0\u0027s and 1\u0027s as follows:\n\n0;00;01;10;000;001;010;011;100;101;110;0000;0001;:::;1011;1110;00000;:::\n\nThe first key in the sequence is of length 1, the next 3 are of length 2, the next 7 of length 3, the next 15 of length 4, etc. If two adjacent keys have the same length, the second can be obtained from the first by adding 1 (base 2). Notice that there are no keys in the sequence that consist only of 1\u0027s.\n\nThe keys are mapped to the characters in the header in order. That is, the first key (0) is mapped to the first character in the header, the second key (00) to the second character in the header, the kth key is mapped to the kth character in the header. For example, suppose the header is:\n\nAB#TANCnrtXc\n\nThen 0 is mapped to A, 00 to B, 01 to #, 10 to T, 000 to A, ..., 110 to X, and 0000 to c.\n\nThe encoded message contains only 0\u0027s and 1\u0027s and possibly carriage returns, which are to be ignored.The message is divided into segments. The first 3 digits of a segment give the binary representationof the length of the keys in the segment. For example, if the first 3 digits are 010, then the remainderof the segment consists of keys of length 2 (00, 01, or 10). The end of the segment is a string of 1\u0027s which is the same length as the length of the keys in the segment. So a segment of keys of length 2 is terminated by 11. The entire encoded message is terminated by 000 (which would signify a segmentin which the keys have length 0). The message is decoded by translating the keys in the segments one-at-a-time into the header characters to which they have been mapped.\n\nInput\n\nThe input file contains several data sets. Each data set consists of a header, which is on a single lineby itself, and a message, which may extend over several lines. The length of the header is limitedonly by the fact that key strings have a maximum length of 7 (111 in binary). If there are multiplecopies of a character in a header, then several keys will map to that character. The encoded message contains only 0\u0027s and 1\u0027s, and it is a legitimate encoding according to the described scheme. That is,the message segments begin with the 3-digit length sequence and end with the appropriate sequence of1\u0027s. The keys in any given segment are all of the same length, and they all correspond to characters inthe header. The message is terminated by 000.\n\nCarriage returns may appear anywhere within the message part. They are not to be considered as part of the message.\n\nOutput\n\nFor each data set, your program must write its decoded message on a separate line. There should not be blank lines between messages.\n\nSample input\n\nTNM AEIOU\n0010101100011\n1010001001110110011\n11000\n$#**\\\n0100000101101100011100101000\n\nSample output\n\nTAN ME\n##*\\$\n\n一些信息编码方案要求编码后的信息要分两部分发送,第一部分称为报头,包含信息的字符。第一部分称为报头,包含电文的字符。第二部分包含一个表示信息的模式。你必须编写一个能够在这种方案下解码消息的程序。\n\n你的程序编码方案的核心是一个由0和1组成的 \"key \"字符串序列,如下所示。\n\n0;00;01;10;000;001;010;011;100;101;110;0000;0001;:::;1011;1110;00000;:::\n\n序列中第一个键的长度为1,接下来的3个键的长度为2,接下来的7个键的长度为3,接下来的15个键的长度为4,等等。如果相邻的两个键的长度相同,则可以从第一个键中加1(基数2)得到第二个键。注意,序列中没有只由1组成的键。\n\n键按顺序映射到头中的字符。也就是说,第一个键(0)被映射到头的第一个字符,第二个键(00)被映射到头的第二个字符,第k个键被映射到头的第k个字符。例如,假设报头为\n\nAB#TANCnrtXc\n\n然后0映射到A,00映射到B,01映射到#,10映射到T,000映射到A,...,110映射到X,0000映射到c。\n\n编码后的信息只包含0和1,可能还有回车,这些都要被忽略。一个段的前3位数字给出了该段中键的长度的二进制表示。例如,如果前3位数字是010,那么段的其余部分由长度为2的键组成(00、01或10)。段的结尾是一串1,长度与段中键的长度相同。因此,一个长度为2的密钥段以11结束。整个编码信息以000结束(这将标志着一个段中的键的长度为0)。信息是通过将段中的键值逐次翻译成它们已被映射到的头字符来解码的。\n\n输入字段\n\n输入文件包含几个数据集。每个数据集都由一个单行的报头和一个可以扩展到几行的报文组成。 头部的长度仅受限于密钥字符串的最大长度为7(二进制为111)。如果在一个头中有一个字符的多个副本,那么几个键将映射到该字符。编码后的消息只包含0和1,根据所述方案,它是一个合法的编码。也就是说,消息段以3位数的长度序列开始,以适当的1\u0027s序列结束。任何给定段中的密钥都是相同长度的,它们都对应于报头中的字符。消息以000结束。\n\n回车符可以出现在消息部分的任何位置。它们不被认为是消息的一部分。\n\n输出信息\n\n对于每一个数据集,你的程序必须将其解码信息写在单独的一行上。信息之间不应该有空行。\n\n输入示例\n\nTNM AEIOU\n0010101100011\n1010001001110110011\n11000\n$#**\\\n0100000101101100011100101000\n\n样品输出\n\nTAN ME\n##*\\$\n\n"}}]}