Logo
(追記) (追記ここまで)

15071번 - The Key to Cryptography 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB119858071.429%

문제

Suppose you need to encrypt a top secret message like “SEND MORE MONKEYS". You could use a simple substitution cipher, where each letter in the alphabet is replaced with a different letter. However, these ciphers are easily broken by using the fact that certain letters of the alphabet (like ‘E’, ‘S’, and ‘A’) appear more frequently than others (like ‘Q’, ‘Z’, and ‘X’). A better encryption scheme would vary the substitutions used for each letter. One such system is the autokey cipher.

To encrypt a message, you first select a secret word – say “ACM" – and prepend it to the front of the message. This longer string is truncated to the length of the message and called the key, and the n th letter of the key is used to encrypt the n th letter of the original message. This encryption is done by treating each letter in the key as a cyclic shift value for the corresponding letter in the message, where ‘A’ indicates a shift of 0, ‘B’ a shift of 1, and so on. Using “ACM" as the secret word, we would encrypt our message as follows:

 SENDMOREMONKEYS (message)
 ACMSENDMOREMONK (key)
------------------------------
 SGZVQBUQAFRWSLC (ciphertext)

Note that the letter ‘E’ in the message was encrypted as ‘G’ the first time it was encountered (since the corresponding letter in the key was ‘C’ indicating a shift of 2), but then as ‘Q’ and ‘S’ the next two times.

Your task is simple: given a ciphertext and the secret word, you must determine the original message.

입력

Input consists of two lines. The first contains the ciphertext and the second contains the secret word. Both lines contain only uppercase alphabetic letters.

출력

Display the original message that generated the given ciphertext using the given secret word.

제한

예제 입력 1

SGZVQBUQAFRWSLC
ACM

예제 출력 1

SENDMOREMONKEYS

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2016 East Central Regional Contest C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /