#C13393. Shift Alphabets

    ID: 42926 Type: Default 1000ms 256MiB

Shift Alphabets

Shift Alphabets

The problem is to shift each alphabetic character in a given string s by an integer n positions in the alphabet. The shift wraps around, so that characters near the end of the alphabet continue from the beginning. More formally, for a given alphabetic character with ASCII code, the new character is computed using the formula: $$ new\_char = ((\text{ord}(char)-\text{base}+n) \mod 26) + \text{base} $$ where base is the ASCII code for 'a' or 'A' depending on the case of the character. Non-alphabetic characters remain unchanged. If n is less than or equal to zero, the original string is returned unchanged.

Examples:

  • Input: s = "Hello, World!", n = 3 → Output: "Khoor, Zruog!"
  • Input: s = "abcXYZ", n = 2 → Output: "cdeZAB"
  • Input: s = "Python3.6", n = -4 → Output: "Python3.6"

inputFormat

The input is read from STDIN and consists of two lines:

  1. The first line contains a non-empty string s.
  2. The second line contains an integer n.

outputFormat

Output the transformed string after shifting its alphabetic characters by n positions. The result should be printed to STDOUT.

## sample
Hello, World!
3
Khoor, Zruog!