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

33251번 - Encryptastrophy 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB312821100.000%

문제

Alice and Bob are deeply in love, they sometimes like to swap out messages in class because they can't get enough of each other. In order to make sure no-one but them reads these messages, they get together and devise an encryption scheme that is theirs only: Despite what people are saying, security through obscurity does work, right?

To keep things simple, They first map every letter of the alphabet a-z to the numbers 0 to 25.

To encrypt and decrypt, a modular addition cipher is used, which defines the encryption function $E$ and decryption function $D$ as such:

$$ E(k, p) = p + k \mod 26 $$ $$ D(k, c) = c - k \mod 26 $$

$$ c_i = E(k_i, p_i) $$ $$ p_i = D(k_i, c_i) $$

Where $p$ is the plaintext, $c$ is the ciphertext and $k$ is the key.

In order to avoid having to send long keys, they define the key as follows:

$$k_i = p_{i-1} $$

With $k_0$ being predetermined by Bob and Alice.

They feel this is secure and chat away all day long, without a worry in the world.

Eve however, has devised a plan. While spying on them, she's always picked up the last letter of every message that they've sent. She's now bent on figuring out what these messages say.

입력

  • One line with one integer: 1ドル \leq n \leq 10^3,ドル the length of the ciphertext string
  • One line with the ciphertext string
  • One line with the last letter of the plaintext string

출력

The plaintext string

제한

예제 입력 1

8
ftzjzcmi
u

예제 출력 1

iloveyou

예제 입력 2

10
ulpwzkkfco
d

예제 출력 2

helloworld

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2019 E번

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

출처

대학교 대회

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

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