The Hardest Problem EverTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31335 Accepted Submission(s): 14501 Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that no one could figure it out without knowing how it worked. Input Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. All characters will be uppercase. Output For each data set, there will be exactly one line of output. This is the original message by Caesar. Sample Input START NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX END START N BTZQI WFYMJW GJ KNWXY NS F QNYYQJ NGJWNFS ANQQFLJ YMFS XJHTSI NS WTRJ END START IFSLJW PSTBX KZQQ BJQQ YMFY HFJXFW NX RTWJ IFSLJWTZX YMFS MJ END ENDOFINPUT Sample Output IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE |
package hdu.oj;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String c;char[] d;
Scanner sc=new Scanner(System.in);
while(sc.hasNextLine()) {
c=sc.nextLine();
if(c.compareTo("ENDOFINPUT")==0)return ;
if(c.compareTo("START")==0) continue;
if(c.compareTo("END")==0) continue;
int l=c.length();
d = new char[l];
for(int i=0;i<l;i++) {
d[i]=c.charAt(i);
if(d[i]>='F'&&d[i]<='Z') d[i]-=5;
else if(d[i]>='A'&&d[i]<'F') d[i]+=21;
}
System.out.println(d);
}
}
}