Pro.ID22738 TitleVigenere Cipher Analysis Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22738 AC0 Submit0 Ratio- 时间&空间限制描述In this problem set, there is another problem (vigenere) asking you to implement the Vigenere Cipher encryption algorithm. This time, we will demonstrate one of the caveats of that cipher. A secret organization Amateur Codebreakers Movement has a strong suspicion that bank robbers are planning another strike soon. Unfortunately, we do not know neither the name of the bank nor the exact day and time. ACM is able to eavesdrop the communication between robbers and their driver but the communication is encrypted using the Vigenere Cipher. Your task is to try to break the cipher. You are given two words that are likely to appear in the original plaintext — so-called cribs (such words played an important role, for example, in breaking the famous Enigma code). 输入(For the specification of the Vigenere cipher, please refer to the vigenere problem.) The input contains several instances. Each instance consists of four lines — the first line is an integer number K, 1 ≤ K ≤ 100, the maximum length of the encryption key to be considered. The second and third lines contain the cribs W1 and W2, 1 ≤ K ≤ length(Wi) ≤ 100. The fourth line is the ciphertext C, 1 ≤ length(C) ≤ 100000. Both the cribs W1, W2 and the ciphertext C consist only of uppercase letters of the standard English alphabet {A, B, C, ..., Z}. The input is terminated by a line containing one zero. 输出Description In this problem set, there is another problem (vigenere) asking you to implement the Vigenere Cipher encryption algorithm. This time, we will demonstrate one of the caveats of that cipher. A secret organization Amateur Codebreakers Movement has a strong suspicion that bank robbers are planning another strike soon. Unfortunately, we do not know neither the name of the bank nor the exact day and time. ACM is able to eavesdrop the communication between robbers and their driver but the communication is encrypted using the Vigenere Cipher. Your task is to try to break the cipher. You are given two words that are likely to appear in the original plaintext — so-called cribs (such words played an important role, for example, in breaking the famous Enigma code). Input (For the specification of the Vigenere cipher, please refer to the vigenere problem.) The input contains several instances. Each instance consists of four lines — the first line is an integer number K, 1 ≤ K ≤ 100, the maximum length of the encryption key to be considered. The second and third lines contain the cribs W1 and W2, 1 ≤ K ≤ length(Wi) ≤ 100. The fourth line is the ciphertext C, 1 ≤ length(C) ≤ 100000. Both the cribs W1, W2 and the ciphertext C consist only of uppercase letters of the standard English alphabet {A, B, C, ..., Z}. The input is terminated by a line containing one zero. Output Your program must determine how many different plaintexts there exist that contain both of the given cribs simultaneously inside the same message and that will result into the given ciphertext using the Vigenere Cipher with some key Q, 1 ≤ length(Q) ≤ K. Print one line for each input instance:
Sample Input 4 Sample Output WEWILLROBTHEBANKANDTAKEALLTHEMONEYTOMORROWATNOON Source 样例输入4 样例输出WEWILLROBTHEBANKANDTAKEALLTHEMONEYTOMORROWATNOON 作者 |