package yukicoder; import java.util.Scanner; //@see http://yukicoder.me/problems/59 public class No18 { public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); String s = sc.next(); System.out.println(ursarDecoding(s)); // sample(); } private static void sample() { String text = "abc"; String data1 = ceaserEncoding(text, 3); System.out.println(data1); System.out.println(ceaserDecoding(data1, 3)); System.out.println(ursarDecoding("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); System.out.println(ursarDecoding("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")); System.out.println(ursarDecoding("BNOXMKZMNHNQYZTDTWLUMAOCUEBNHHNTTIWIZRGVTRVSNNDBRJNLEERPTAYMMCAAEHXDXHKCIPPLNWTQKMLNSGYBTORRPDUHKCUAAYMDTQGMKLPKDVEFBCQJRAGNCKREGWIGQSGZHQWOOMESPZFQYIMASCQGMCGHJTPVPDSQUSPHKKHZGKSCQSPHWLJUSLOYCYFCUILUAMKKORHTJUZIGKSQNFPGAWKUIKTFGUXABEQVHHYNHBCRPECOCYVDHLDCFLZLMAFERKMZXWDBNWCRLLWOMEKEVHBVSIWOVLCRPDRWHDFJXFDWYJDDBVDXTMVCYYYFUSSUGSKNPNBDQONYKEYCLUJINAAJTDZWGNGUPNDALQIEXZOMWYCYNZIOGWHZNLXLHEMKVQTYAUJBVQQWCJYSMIAPECHRJUKAFZLZBZLZVSACFJXYNLBAHAMNBMSZOWBONAZWCWWJHGODBLNRUJRJNXLTJXOMQVTHZFZNJKRPNRJILRFRPVCOYFVCCEWYXHZNXJBONRDVNYVVCRPMHHWEIOBFGBFPRTPHDPQIVVBSOQEHTCGWKUHAKRLOTVVTFTPMUCLDRCUQHMBWFEKMEFFPVMAKKQBZZEVHXEESLIPNQCLPFTEINTNWODPZRFIXVJXMPHQQNFCCGXWGPVRXRFUOCQEQBHCAOCMTWKFIFYDQCRLXYCIXVJULZAAQPUBTUIQYMZNAFQAHAORJBMZKSCQCBPLRJRVDNKQRNWGIVLVZZSTCSHJPNGFTZXNKVASHWUJHTHDAIYRARWDVWKSAXWPPBUIXVKIIMPPKZNTUSESOLTFRTOUWHDFLVIHILLKYUJHWMUDJNXNTNBXCRDBMJBEYQDZERRXZPBDDTAAHPAZFZNCATYSESKQXMKJWUNPEGCUMVSMBZNAMHNHJLWJONPCYCFRBWELJLQJNHGMAECBESJYWDQSUAUXJZFMBZIXRSESQIJTUKIWNVQABTBCAGAODBNQOHGQCTLAPNGZDXWCWUGZUMAKMSAOAPSWKAZXE")); } public static String ursarDecoding(String text) { String data = ""; for (int i = 0; i < text.length(); i++) { int divi = i % 26; int substRet = char2int(text.charAt(i), divi); int ret; if (substRet <= 0) { ret = "Z".charAt(0) + substRet; } else { ret = ((text.charAt(i) - divi) - 1); } data = data + String.valueOf(Character.toString((char)ret)); } return data; } private static int char2int(char c, int i) { return ((c - 'A') - i); } public static String ceaserEncoding (String text, int no) { String data1 = ""; for (int i = 0; i < text.length(); i++) { data1 = data1 + String.valueOf((char)(text.charAt(i) + no)); } return data1; } public static String ceaserDecoding (String text, int no) { String data1 = ""; for (int i = 0; i < text.length(); i++) { data1 = data1 + String.valueOf((char)(text.charAt(i) - no)); } return data1; } }