#C632. Implementing Caesar Cipher

    ID: 50067 Type: Default 1000ms 256MiB

Implementing Caesar Cipher

Implementing Caesar Cipher

In this problem, you are required to implement the Caesar Cipher encryption method. The Caesar Cipher shifts the letters of a given message by a specified number of positions. Uppercase and lowercase letters must be preserved, and non-alphabetical characters should remain unchanged. The shifting formula for each alphabetical character is given by:

$$ c = \text{mod}((\text{ord}(ch) - \text{ord}(base) + shift), 26) + \text{ord}(base) $$

where base is 'A' for uppercase letters and 'a' for lowercase letters.

inputFormat

The input consists of two lines:

  • The first line is a string representing the original message. This string may contain spaces, numbers, punctuation, and other symbols.
  • The second line is an integer that represents the shift amount.

outputFormat

Output a single line containing the encrypted message. The message should be encrypted by applying the Caesar Cipher with the given shift value.

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

</p>