Ethel's Encryption
InterviewTime limit1sMemory limit256 MB
Recover the plaintext by computing the Caesar shift a^b modulo 26 and moving each ciphertext letter back by that amount.
- Level
Easy3 of 10
- Topics
- Number theory, String, Implementation
- Solved
- No attempts yet
Problem
Ethel suspected that the North Side Alliance (NSA) was reading the messages she exchanged with her sister Lucy. To stop them, Ethel encrypted every message with a Caesar cipher.
A Caesar cipher shifts each letter of the plaintext forward by a fixed offset to produce the ciphertext. With an offset of 2, A becomes C, B becomes D, and Y becomes A.
The offset is . Given the ciphertext, recover the original message.
Input
The first line contains three integers , , and . Here is the number of characters in the ciphertext, spaces included. The offset is computed as , with and . In every input at least one of and is greater than 0.
The second line contains the characters of the ciphertext. The ciphertext consists only of upper-case letters (A-Z) and spaces, and a newline follows it immediately.
Output
Print the decrypted message in upper-case letters on a single line. Spaces stay in the positions they occupy in the ciphertext. Print a newline immediately after that line.