QOJ.ac

QOJ

时间限制: 1 s 内存限制: 128 MB 总分: 100 可 Hack ✓

#17187. Vigenère Cipher

统计

In the 16th century, the French diplomat Blaise de Vigenère designed a polyalphabetic cipher algorithm known as the Vigenère cipher. The Vigenère cipher is simple to use and difficult to break, and it was widely used by the Confederate Army during the American Civil War.

In cryptography, the information to be encrypted is called the plaintext, denoted by $M$; the encrypted information is called the ciphertext, denoted by $C$; and the key is a parameter, which is the data input into the algorithm that converts plaintext to ciphertext or ciphertext to plaintext, denoted by $k$. In the Vigenère cipher, the key $k$ is a string, $k=k_1k_2\cdots k_n$. When the plaintext $M=m_1m_2\cdots m_n$, the resulting ciphertext is $C=c_1c_2\cdots c_n$, where $c_i=m_i\otimes k_i$. The rules of the operation are shown in the table below:

When performing Vigenère encryption, note the following:

  1. The $\otimes$ operation ignores the case of the letters involved in the operation and preserves the case of the letters as they appear in the plaintext $M$.
  2. When the length of the plaintext $M$ is greater than the length of the key $k$, the key $k$ is used repeatedly.

For example, if the plaintext $M=\text{Helloworld}$ and the key $k=\text{abc}$, the ciphertext $C=\text{Hfnlpyosnd}$.

Plaintext: H e l l o w o r l d Key: a b c a b c a b c a Ciphertext: H f n l p y o s n d

Input

The input consists of $2$ lines.

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

Output

Output a single line containing a string representing the plaintext corresponding to the input key and ciphertext.

Examples

Input 1

CompleteVictory
Yvqpxaimmklongnzfwpvxmniytm

Output 1

Wherethereisawillthereisaway

Subtasks

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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.