【Gym 102222C --- Caesar Cipher】

题目来源:点击进入【Gym 102222C — Caesar Cipher】

Description

In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions up (or down) the alphabet.

For example, with the right shift of 19, A would be replaced by T, B would be replaced by U, and so on. A full exhaustive list is as follows:

  • The plaintext: 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;
  • The ciphertext: 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.

Now you have a plaintext and its ciphertext encrypted by a Caesar Cipher. You also have another ciphertext encrypted by the same method and are asked to decrypt it.

Input

The input contains several test cases, and the first line is a positive integer T indicating the number of test cases which is up to 50.

For each test case, the first line contains two integers n and m (1≤n,m≤50) indicating the length of the first two texts (a plaintext and its ciphertext) and the length of the third text which will be given. Each of the second line and the third line contains a string only with capital letters of length n, indicating a given plaintext and its ciphertext respectively. The fourth line gives another ciphertext only with capital letters of length m.

We guarantee that the pair of given plaintext (in the second line) and ciphertext (in the third line) is unambiguous with a certain Caesar Cipher.

Output

For each test case, output a line containing Case #x: T, where x is the test case number starting from 1, and T is the plaintext of the ciphertext given in the fourth line.

Sample Input

1
7 7
ACMICPC
CEOKERE
PKPIZKC

Sample Output

Case #1: NINGXIA

解题思路:

只需判断两个字符串中第一位即可,标记明文和密文之间间隔多少个,然后对应输出即可。

AC代码(C++):

#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
map<char,char> mp;
string s1,s2,s3;int main()
{int n,m,t,cas=1;cin >>t;while(t--){cin >> n >> m;cin >> s1 >> s2;int x = (s1[0]-s2[0]+26)%26;cin >> s3;cout << "Case #" << cas++ <<": ";for(int i=0;i<m;i++) cout << char((s3[i]-'A'+x)%26+'A');cout << endl;mp.clear();}return 0;
}

【Gym 102222C --- Caesar Cipher】相关推荐

  1. Codeforces - 102222C - Caesar Cipher

    https://codeforc.es/gym/102222/my 好像在哪里见过这个东西?字符的左右移还是小心,注意在mod26范围内. #include<bits/stdc++.h> ...

  2. G - Caesar Cipher Gym - 102798G

    G - Caesar Cipher Gym - 102798G 题意: 对于一个区间,有两种操作,一种是对区间每个数+1再mod65536,另一种则是判断两个区间的数是否相同 题解: 参考题解: 很明 ...

  3. 【JS 逆向百例】webpack 改写实战,G 某游戏 RSA 加密

    关注微信公众号:K哥爬虫,QQ交流群:808574309,持续分享爬虫进阶.JS/安卓逆向等技术干货! 声明 本文章中所有内容仅供学习交流,抓包内容.敏感网址.数据接口均已做脱敏处理,严禁用于商业用途 ...

  4. 毕业准备:外企面试--基本涵盖了所有问题【附带有答案版本】

    毕业准备:外企面试--基本涵盖了所有问题[附带有答案版本] 2011-03-06 00:03:57 1. So, tell me a little about yourself. You don't ...

  5. 【网络编程开发系列】好端端的MQTT-broker重新部署后居然出现TLS握手失败了

    摘要:本文通过一次真实的现网案例复盘,深度还原TLS握手问题的排查思路和方法,希望对广大读者有所启发和帮助. 文章目录 1 写在前面 2 问题描述 2.1 项目背景 2.2 现场问题 3 场景复现 3 ...

  6. 【Wi-Fi 802.11协议】管理帧 之 Beacon帧详解

    Beacon帧简介 信标帧,由AP以一定的时间间隔周期性发出,以此来告诉外界自己无线网络的存在. Beacon帧组成 下图为Beacon帧的组成 下图为抓包所得(AP为2.4g 11n模式),Pack ...

  7. 【一文弄懂】优先经验回放(PER)论文-算法-代码

    [一文弄懂]优先经验回放(PER)论文-算法-代码 文章目录 [一文弄懂]优先经验回放(PER)论文-算法-代码 前言: 综合评价: 继续前言唠叨 per论文简述: 参考博客: 背景知识 A MOTI ...

  8. 【强化学习实战-04】DQN和Double DQN保姆级教程(2):以MountainCar-v0

    [强化学习实战-04]DQN和Double DQN保姆级教程(2):以MountainCar-v0 实战:用Double DQN求解MountainCar问题 MountainCar问题详解 Moun ...

  9. 【华为_数通】OSPF

    OSPF OSPF基础 OSPF概述 OSPF区域 OSPF区域类型 OSPF路由器类型 OSPF工作流程 OSPF报文和状态 Router ID OSPF报文 字段验证 Hello定时器 7种状态 ...

最新文章

  1. java 调用office_JAVA调用PageOffice在线打开、编辑Word文档
  2. android远程桌面软件毕设_向日葵远程管理软件
  3. es6 Promise,生成器函数,async
  4. 2021-10-28 python爬虫学习
  5. python中itertools的用法,【python日用】itertools.product用法
  6. 企业之HA~cluster
  7. 使用phpqrcode来生成二维码/thinkphp
  8. 2021 年 338 道架构技术面试大厂高频题汇总(附答案详解)
  9. 光伏电池最大功率跟踪
  10. 组态王、力控等传统组态软件通过互联网远程监控PLC
  11. 统计|如何观测两变量之间的相关系数及含义
  12. CentOS7下docker服务无法启动的一般检查
  13. Unable to start debugging.报错
  14. Windows Print Spooler远程代码执行漏洞复现(CVE-2021-1675)
  15. 论文小技巧-pdf转eps使色彩保持RGB不变及去边框
  16. 3D游戏模型教程系列:3D max安装
  17. 数据库八股文--藤原豆腐店自用
  18. IT大学生成长周报 | 第 5 期
  19. DDR,DDR2,DDR3,DDR4,LPDDR区别
  20. 孩子数学成绩不好怎么办_小孩子数学差怎么办

热门文章

  1. 包装行业智慧供应链系统:加快产业周转效率,改善业务处理流程
  2. MAC本地服务器搭建
  3. 易友姓名测试软件发布
  4. 虚拟机 ubuntu 无法和共享主机网络 no wifi adapter found 解决方案
  5. Python_基础_(迭代器,生成器)
  6. Starday作为增速快的电商潜力市场 ,入驻商户能够轻松实现旺季“躺平”
  7. CVPR 2023上46篇AIGC论文和代码
  8. Telnet登录、ssh登录
  9. 安装Office2016遇到“无法流式传输Office”问题
  10. 查询快递单号物流,查看物流信息