Encryptastrophy
Time limit1sMemory limit2048 MB
Given a ciphertext where each letter is the mod 26 sum of a plaintext letter and the plaintext letter before it, plus the last plaintext letter, recover the full plaintext.
- Level
Easy2 of 10
- Topics
- String, Simulation
- Solved
- No attempts yet
Problem
Alice and Bob are deeply in love. They often swap messages in class because they cannot get enough of each other. To make sure no one but them can read these messages, they devise an encryption scheme that belongs only to them. Security through obscurity does work, right?
They map each letter a-z to the numbers 0 to 25. They use a modular addition cipher with the encryption function and the decryption function :
Here is the plaintext, is the ciphertext, and is the key.
To avoid sending long keys, they define the key as
where is predetermined by Bob and Alice.
They believe this is secure, and they chat all day without a worry.
Eve has been spying on them. Each time they send a message, she picks up the last letter of it. She wants to find out what the messages say.
Input
- One line with one integer: , the length of the ciphertext string.
- One line with the ciphertext string.
- One line with the last letter of the plaintext string.
Output
The plaintext string.