| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 31 | 28 | 21 | 100.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.
The plaintext string
8 ftzjzcmi u
iloveyou
10 ulpwzkkfco d
helloworld