QOJ.ac

QOJ

Límite de tiempo: 10.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#6992. 凯撒密码

Estadísticas

在密码学中,凯撒密码(Caesar cipher),也称为移位密码,是最直接且广为人知的加密技术之一。它是一种替换加密,其中明文中的每个字母都被字母表中固定位置之后(或之前)的某个字母所替换。

例如,向右移动 19 位时,A 将被 T 替换,B 将被 U 替换,依此类推。完整的对应列表如下:

明文:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 密文:T U V W X Y Z A B C D E F G H I J K L M N O P Q R S

现在你已知一段由凯撒密码加密的明文及其对应的密文。同时,你还拥有另一段由相同方法加密的密文,请将其解密。

输入格式

输入包含多个测试用例,第一行是一个正整数 $T$,表示测试用例的数量,最多为 50 个。

对于每个测试用例,第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 50$),分别表示前两段文本(一段明文及其对应的密文)的长度,以及将要给出的第三段文本的长度。第二行和第三行各包含一个长度为 $n$ 的仅由大写字母组成的字符串,分别表示给定的明文及其对应的密文。第四行给出另一个长度为 $m$ 的仅由大写字母组成的密文。

我们保证给定的明文(第二行)和密文(第三行)对是由唯一的某种凯撒密码加密得到的。

输出格式

对于每个测试用例,输出一行 Case #x: T,其中 $x$ 是从 1 开始的测试用例编号,$T$ 是第四行给出的密文对应的明文。

样例

输入格式 1

1
7 7
ACMICPC
CEOKERE
PKPIZKC

输出格式 1

Case #1: NINGXIA

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.