The hardest problem ever
Problem Descriptionjulius 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 is so incredibly sound, and that's no one could figure it out without knowing how it worked.
You are a sub captain of Caesar ' s army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each of the plaintext message, you shift it five places to the right to create the secure message (i.e., if the L Etter is ' A ', the cipher text would was ' F '). Since you is creating plain text out of Caesar ' s messages, you'll do the opposite:
Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
Only letters is shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters would be a upper case.
Inputinput to this problem would consist of a (Non-empty) series of up to data sets. Each data set is formatted according to the following description, and there would be no blank lines separating data s Ets. All characters would be uppercase.
A Single Data set have 3 components:
Start Line-a single line, "Start"
Cipher message-a single line containing from one to the other hundred characters, inclusive, comprising A single message from Caesar
End Line-a single line, "End"
Following the final data set would be a, "endofinput".
Outputfor each data set, there is exactly one line of output. The original message by Caesar.
Sample Input
Startns BFW, Jajsyx tk nrutwyfshj fwj ymj wjxzqy tk ywnanfq hfzxjxendstartn btzqi wfymjw GJ knwxy NS F qnyyqj NGJWNFS ANQQ Flj Ymfs xjhtsi NS wtrjendstartifsljw pstbx kzqq bjqq ymfy hfjxfw NX rtwj ifsljwtzx Ymfs mjendendofinput
Sample Output
In WAR, EVENTS of importance is the RESULT of TRIVIAL Causesi would rather be first in A LITTLE Iberian VILLAGE THAN SECO ND in Romedanger KNOWS full well, CAESAR is more dangerous THAN HE
amount ... Water a bar. Enter a string of strings to be output in "vwxyzabcdefghijklmnopqrstu" order according to the character position. See the code specifically:
#include <cstdio> #include <cstring>int main () { char fl[27]= "Vwxyzabcdefghijklmnopqrstu", s[1010]; while (gets (s)) { if (strcmp (s), "START") ==0); else if (strcmp (S, "END") ==0); else if (strcmp (S, "Endofinput") ==0) break; else{ for (int i=0;i<strlen (s); i++) { if (s[i]>= ' A ' &&s[i]<= ' Z ') printf ("%c", fl[s[i]-' A ']); else printf ("%c", S[i]); } printf ("\ n");} } return 0;}
because the open string is not long enough, WA once.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 1048.The hardest problem ever "string processing" "August 25"