Virus
InterviewTime limit2sMemory limit512 MB
Given a key and one line of ciphertext, undo a Caesar variant whose shift grows by one per letter and resets after 25.
- Level
Easy2 of 10
- Topics
- String, Simulation, Implementation
- Solved
- No attempts yet
Problem
Shroeder and Patsy heard about a friend whose computer was hit by a ransom virus. A message on his screen said that every file had been encrypted and that getting the files back would cost money.
Both of them like programming, so they wondered how that works and wrote a simple cipher of their own, just for fun. Its key is a single number.
The method is a variant of the Caesar cipher. The alphabet is circular, so a follows z. Start with a shift between 1 and 25, which is the key, and increase the shift by one for every letter. Once the shift passes 25 it becomes 1 again.
Only lowercase letters are shifted. Spaces, digits and punctuation marks are copied unchanged and do not advance the shift.
Decrypting is easy once you know the key, as long as you shift in the opposite direction. Given the key and one line of ciphertext, print the original text.
Input
The first line contains the key ().
The second line contains the encrypted text. It is at most 250 characters long and consists of lowercase letters, spaces, digits and punctuation marks only.
Output
Print the decrypted line of text.