2017-03-18 22:17:22 -05:00
|
|
|
// Author: Rodney Shaghoulian
|
2018-07-27 16:45:56 -07:00
|
|
|
// Github: github.com/RodneyShag
|
|
|
|
|
// HackerRank: hackerrank.com/RodneyShag
|
2017-03-18 22:17:22 -05:00
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
public class Solution {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Scanner scan = new Scanner(System.in);
|
|
|
|
|
int length = scan.nextInt();
|
|
|
|
|
String str = scan.next();
|
|
|
|
|
int K = scan.nextInt();
|
|
|
|
|
scan.close();
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
|
char ch = str.charAt(i);
|
|
|
|
|
sb.append(encrypt(ch, K));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println(sb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Encrypts a character using Caesar Cipher */
|
|
|
|
|
private static char encrypt(char ch, int K) {
|
|
|
|
|
if (!Character.isLetter(ch)) {
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
char base = Character.isLowerCase(ch) ? 'a' : 'A';
|
|
|
|
|
return (char) ((ch - base + K) % 26 + base);
|
|
|
|
|
}
|
|
|
|
|
}
|