#T690. 【NOIP2012-S2】Vigenère 密码

【NOIP2012-S2】Vigenère 密码

Description

In the 16th century, French diplomat Blaise de Vigenère designed a polyalphabetic cipher encryption algorithm called the Vigenère cipher. The Vigenère cipher's encryption and decryption algorithms are simple to use and relatively difficult to crack, and it was widely employed by the Southern forces during the American Civil War.

In cryptography, the information to be encrypted is called plaintext, denoted as M; the encrypted information is called ciphertext, denoted as C; and the key is a parameter—a piece of data input into the algorithm that transforms plaintext into ciphertext or vice versa—denoted as k. In the Vigenère cipher, the key k is a string of letters, k=k₁,k₂,…,kₙ. When the plaintext M=m₁,m₂,…,mₙ, the resulting ciphertext C=c₁,c₂,…,cₙ, where cᵢ=mᵢ®kᵢ, and the operation ® follows the rules shown in the table below:

0052A.png When applying Vigenère encryption, note the following: 1. The ® operation ignores the case of the letters involved and preserves the case of the plaintext M; 2. If the length of plaintext M exceeds the length of key k, the key k is repeated. For example, if plaintext M=Helloworld and key k=abc, the ciphertext C=Hfnlpyosnd.

0052B.png

Input Format

The input consists of 2 lines.

The first line is a string representing the key k, with a length not exceeding 100 and containing only uppercase and lowercase letters. The second line is a string representing the encrypted ciphertext, with a length not exceeding 1000 and containing only uppercase and lowercase letters.

Output Format

The output consists of 1 line, a string representing the plaintext corresponding to the input key and ciphertext.

```input1 CompleteVictory Yvqgpxaimmklongnzfwpvxmniytm ``` ```output1 Wherethereisawillthereisaway ``` ## Hint

【Data Specification】

For 100% of the data, the length of the input key does not exceed 100, and the length of the input ciphertext does not exceed 1000. Both contain only English letters.

Source

NOIP2012-S2-Day2-T2