#P3982. 龙盘雪峰信息解析器
龙盘雪峰信息解析器
Description
Messages from Longpan Snow Peak are encrypted into complex codes. We need you to write a program that deciphers these codes according to the rules below and translates them into text.
The code is a continuous string of binary digits (only and ; when adding, carry whenever it reaches ; each or occupies one character). Every eight characters form one unit (this is also a rule).
Each unit follows these rules:
- If the first three characters are , the unit represents a letter . The code for is , the code for is . The uppercase letters are arranged in alphabetical order following this pattern, each corresponding to a unique binary code.
- If the first three characters are , the unit translates to a space.
- If the first character is , then the unit represents a number to be added to the number represented by the next unit. During this addition, convert these two units to decimal, then divide each by and discard the remainder before adding. After the addition, the sum is the translation result for these two units (the result is expressed in decimal). Both of these units are then considered fully translated (see Sample ).
For safety, Longpan Snow Peak often sends “fake code,” which does not follow the rules above. If fake code appears, only output Error.
Input Format
The input contains a single line with a continuous code string (length does not exceed characters). No spaces will appear, and the input is guaranteed to be non-empty.
Output Format
Output a single line containing the string produced by translating the binary code according to the rules above.
If the binary code contains any fake code, only output Error.
1010000011100000101011111010100010100110
A PIG
1
Error
0000001000000010000000100000001010100000
22A
IOIOOOOI
Error
Hint
Explanation for Sample :
represents . The next unit begins with , which translates to a space. The next unit begins with and is followed by , which is more than , so it represents . By analogy, the final translation is .
Note:
For Rule : the uppercase letters are arranged in alphabetical order, starting from . Each subsequent letter’s binary code has a value exactly greater than the previous letter’s binary code (remember to carry in base ).
This problem is prone to misunderstandings. Please read the statement carefully, clarify the logical relationships, and pay attention to details.
Translated by ChatGPT 5
京公网安备 11011102002149号