#t211. 凯撒密码
凯撒密码
Caesar Cipher
Problem Background
Special for beginners, ^_^
Problem Description
Julius Caesar was very clever and came up with a simple and effective encryption system: given any lowercase English letter , just take the 3rd letter after it as its encrypted letter; the last 3 letters map cyclically back to the first 3 letters.
The encryption scheme is as follows:
$a\rightarrow d,\,b\rightarrow e,\,c\rightarrow f,\,\cdots,\,x\rightarrow a,\,y\rightarrow b,\,z\rightarrow c$
Now you are given a character ; please give its encrypted letter!
Input Format
One lowercase English letter.
Output Format
One lowercase English letter: the encrypted letter.
Sample Input 1
a
Sample Output 1
d
Sample Input 2
x
Sample Output 2
a
Constraints
1s, 1024KiB for each test case.
Hint
- Letters can be added to or subtracted from integers:
c + 3just counts three letters forward. - The trouble is that x, y, z go past
'z'— think about how to wrap them back around to'a'. Modular arithmetic may help (first turning the letter into a 0–25 index makes things easier). - Check against the samples:
a→d;x→a.