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:

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 Format

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 nn and m~(1 \le n,m \le 50)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 Format

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.

样例输入


ACMICPC
CEOKERE
PKPIZKC

样例输出

Case #: NINGXIA

挺简单的一道题,刚开始竟然wa了。。。太菜了

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <math.h>
const int INF=0x3f3f3f3f;
typedef long long LL;
const int mod=1e9+;
const int maxn=1e5+;
using namespace std;
//ios::sync_with_stdio(false);
// cin.tie(NULL); int main()
{
int T;
cin>>T;
for(int k=;k<=T;k++)
{
int n,m;
cin>>n>>m;
string s1,s2,s3;
cin>>s1>>s2;
int p=s1[]-s2[];
cin>>s3;
cout<<"Case #"<<k<<": ";
for(int i=;i<m;i++)
{
cout << char((s3[i]-'A'+p +)% + );
}
cout<<endl;
}
return ;
}

2018 ACM-ICPC 宁夏 C.Caesar Cipher(模拟)的更多相关文章

  1. [UVA227][ACM/ICPC WF 1993]Puzzle (恶心模拟)

    各位大佬都好厉害…… 这个ACM/ICPC1993总决赛算黄题%%% 我个人认为至少要绿题. 虽然算法上面不是要求很大 但是操作模拟是真的恶心…… 主要是输入输出的难. 对于ABLR只需要模拟即可 遇 ...

  2. ACM/ICPC 之 用双向链表 or 模拟栈 解“栈混洗”问题-火车调度(TSH OJ - Train)

    本篇用双向链表和模拟栈混洗过程两种解答方式具体解答“栈混洗”的应用问题 有关栈混洗的定义和解释在此篇:手记-栈与队列相关 列车调度(Train) 描述 某列车调度站的铁道联接结构如Figure 1所示 ...

  3. 2018 ACM ICPC 南京赛区 酱油记

    Day 1: 早上6点起床打车去车站,似乎好久没有这么早起床过了,困到不行,在火车上睡啊睡就睡到了南京.南航离南京南站很近,地铁一站就到了,在学校里看到了体验坐直升机的活动,感觉很强.报道完之后去吃了 ...

  4. 2018 ACM/ICPC 南京 I题 Magic Potion

    题解:最大流板题:增加两个源点,一个汇点.第一个源点到第二个源点连边,权为K,然后第一个源点再连其他点(英雄点)边权各为1,然后英雄和怪物之间按照所给连边(边权为1). 每个怪物连终点,边权为1: 参 ...

  5. HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  6. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  7. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  8. hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...

  9. 【转】lonekight@xmu·ACM/ICPC 回忆录

    转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...

随机推荐

  1. Apache的网站,使用Nginx进行反向代理(1个IP绑定多个域名,对应多个网站)解决方案

    同一个端口是不能同时有两个程序监听的.所以换个思路解决同一台服务器下某些网站运行在nginx下,某些网站运行在Apache下共存. 解决思路: 将nginx作为代理服务器和web服务器使用,nginx ...

  2. pycharm和python安装

    1.pycharm安装:https://www.cnblogs.com/dcpeng/p/9031405.html 2,python安装:https://www.liaoxuefeng.com/wik ...

  3. POJ - 1127 Jack Straws(几何)

    题意:桌子上放着n根木棍,已知木棍两端的坐标.给定几对木棍,判断每对木棍是否相连.当两根木棍之间有公共点或可以通过相连的木棍间接的连在一起,则认为是相连的. 分析: 1.若线段i与j平行,且有部分重合 ...

  4. C++ Opencv播放AVI

    #include "cxcore.h" #include "cvcam.h" #include "windows.h" #include & ...

  5. HyperLedger Cello学习笔记

    HyperLedger Cello学习笔记 转载请注明出处:HyperLedger Cello学习笔记 概述 Hyperledger Cello是Hyperledger下的一个子项目,其主要功能如下: ...

  6. composer命令卡慢,使用国内源

    执行composer install.update 和require的时候,遇到卡住不动的情况,可以切换到国内阿里云的源 composer config -g repo.packagist compo ...

  7. 文献阅读报告 - Situation-Aware Pedestrian Trajectory Prediction with Spatio-Temporal Attention Model

    目录 概览 描述:模型基于LSTM神经网络提出新型的Spatio-Temporal Graph(时空图),旨在实现在拥挤的环境下,通过将行人-行人,行人-静态物品两类交互纳入考虑,对行人的轨迹做出预测 ...

  8. SeetaFaceEngine系列2:Face Alignment编译和使用

    前面一篇写了编译人脸检测部分,现在就介绍下人脸配准部分,SeetaFace的Face Alignment通过人脸的五个关键点来配准人脸,也就是双眼.鼻尖.两个嘴角. 这部分的编译也和上一篇一样,步骤如 ...

  9. java 单利模式设计原理,饿汉式懒汉式,开发中推荐饿汉式

    单例模式的设计:  1 //Single类进内存,对象还没有存在,只有调用了getInstance方法时,才建立对象. //对象是方法被调用时,才初始化,也叫做对象的延时加载.成为:懒汉式. //Si ...

  10. Python笔记_第一篇_面向过程_第一部分_0.开场白

    *什么是Python? Python是一种面向对象的解释型计算机程序设计语言,由荷兰人Guido(吉多) van Rossum于1989年发明,第一个公开版本发行于1991年.在国外应用非常的广泛,国 ...