#P1914. Cyclic String Shift

    ID: 15196 Type: Default 1000ms 256MiB

Cyclic String Shift

Cyclic String Shift

Given an original string s consisting of at most 50 lowercase letters and an integer n, form a new password by shifting each letter in s n positions forward in the alphabet. The shift is cyclic, i.e. after z comes a.

The transformation for each character c can be represented by the formula: $$ c' = \text{chr}(((\text{ord}(c)-\text{ord}('a') + n) \bmod 26) + \text{ord}('a')) $$ where \text{ord}(c) gives the ASCII value of c and \text{chr}(x) converts an integer x back to a character.

inputFormat

The input consists of two lines:

  1. The first line contains the original string s (only lowercase letters, with length at most 50).
  2. The second line contains a positive integer n, indicating the number of positions to shift.

outputFormat

Output the resulting password string after shifting every character of s by n positions.

sample

abc
1
bcd