The hardest problem in history
Time Limit: 1000MS |
|
Memory Limit: 10000K |
Total Submissions: 24958 |
|
Accepted: 13565 |
Description
Julian Caesar lives in an age of danger and intrigue, and the hardest of all is to survive. So he invented one of the earliest cipher systems for the army's message delivery.
Suppose you are an officer in the Caesar Corps who needs to decipher the message sent by Caesar and provide it to your general. Message encryption is done by replacing each letter in the original message with the 5th letter of the letter (for example: Each letter A in the original message is replaced with the letter F). And you want to get the message in the original, which is to reverse the process.
Password Letter: 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
Original text mother: 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
Note: Only letters are replaced, other non-alphabetic characters are not changed, and all letters in the original message are capitalized.
Input
No more than 100 datasets, no blank rows between each dataset, and each dataset consists of 3 parts:
- Start line: Start
- Password message: A line consisting of 1 to 200 characters representing a message from Caesar.
- Ending line: End
After the last dataset, there is another line: Endofinput
Output
One row for each dataset is the original message of 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
As a result of learning Network security course, this topic has done experiments before, is a Caesar password problem, that is, the character moved forward 5 times, pay attention to modulo 26
#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;char S[105];char t[16] ; int main () {int i,j;while (scanf ("%s", T)) {if (strcmp (t, "endofinput") ==0) Break;getchar (); Gets (s); for (i=0;s[i]!= ' ; i++) {if (s[i]>= ' a ' &&s[i]<= ' Z ') s[i]= (s[i]-' a ' +26-5)%26+ ' a ';} scanf ("%s", T);p UTS (s);} return 0;}
POJ 1298 The most difficult question in history--Caesar code