#P5000. Hillwer Encoding Conversion
Hillwer Encoding Conversion
Hillwer Encoding Conversion
Z country is highly advanced in technology, and always the target of various countries. Y country’s hackers intercepted n original codes encoded with the mysterious Hillwer coding. They also discovered the conversion rule of Hillwer encoding, but they are too exhausted to perform the conversion.
Your task is to help Y country by converting Hillwer encoding. For each original code S (which is guaranteed to consist only of 26 uppercase English letters), perform the following steps:
Step 1: Shift every character in S forward by R positions in the alphabet (cyclically). In other words, each letter c is converted to char('A' + ((c - 'A' + R) \mod 26))
. For example, if S = "XYZ" and R = 2, then the intermediate code S1 = "ZAB".
Step 2: Perform a "symbol-to-number" operation on S1 by taking the ASCII code (in \(\LaTeX\): \(\text{ASCII}(\cdot)\)) of each character and multiplying them together to obtain a number Q.
You must output the intermediate code S1 along with the computed number Q for each original code.
You will be awarded the honor of NOIP_AK Glory Laurel if you succeed!
inputFormat
The first line contains two integers n and R, where n is the number of intercepted original codes, and R is the number of positions to shift.
Then follow n lines, each containing a string S consisting solely of uppercase English letters.
outputFormat
For each original code, output a line with the intermediate code S1 and the final converted number Q separated by a space.
sample
1 2
XYZ
ZAB 386100
</p>