#C11275. Decoding Shifted Strings
Decoding Shifted Strings
Decoding Shifted Strings
Given a non-negative integer k
and a string s
composed of lowercase English letters, your task is to decode the string by shifting each character k
positions back in the alphabet. The shifting is cyclic, meaning that after 'a' comes 'z'.
The decoding process is defined by the following formula in LaTeX:
$$ c = \Bigl( (\text{ord}(\text{ch}) - \text{ord}('a') - k) \mod 26 \Bigr) + \text{ord}('a') $$
For example, if k = 3
and s = "def"
, the output should be "abc"
.
inputFormat
The first line of input contains an integer T
, denoting the number of test cases. Each of the following T
lines contains a test case with an integer k
and a string s
separated by space.
For example:
3 3 def 2 hijk 5 mnop
outputFormat
For each test case, output the decoded string on a new line.
For the above example, the output would be:
abc fghi hijk## sample
1
3 def
abc
</p>