#C1897. Caesar Cipher Encryption

    ID: 45152 Type: Default 1000ms 256MiB

Caesar Cipher Encryption

Caesar Cipher Encryption

In this problem, you are required to implement the Caesar Cipher encryption method. Given a text and an integer shift, each alphabetic character in the text should be shifted by the specified number of positions in the alphabet. The shifting is cyclical, i.e., after 'Z' comes 'A' and after 'z' comes 'a'. Non-alphabetic characters remain unchanged.

The mathematical formulation for the shift of a letter c is given by:

\( c' = \text{base} + ((c - \text{base} + \text{shift}) \mod 26) \)

where \( \text{base} \) is \( 'A' \) for uppercase letters and \( 'a' \) for lowercase letters.

It is guaranteed that the input text will only contain ASCII characters.

inputFormat

The input is provided on two lines via standard input. The first line contains the string to be encrypted, and the second line contains an integer representing the shift amount.

outputFormat

Output the resulting encrypted string to standard output.## sample

abc
1
bcd