Codeforces - 102222C - Caesar Cipher
https://codeforc.es/gym/102222/my
好像在哪里见过这个东西?字符的左右移还是小心,注意在mod26范围内。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read() {
int x=0;
int f=0;
char c;
do {
c=getchar();
if(c=='-')
f=1;
} while(c<'0'||c>'9');
do {
x=(x<<3)+(x<<1)+c-'0';
c=getchar();
} while(c>='0'&&c<='9');
return f?-x:x;
}
inline void _write(int x) {
if(x>9)
_write(x/10);
putchar(x%10+'0');
}
inline void write(int x) {
if(x<0) {
putchar('-');
x=-x;
}
_write(x);
putchar('\n');
}
void TestCase(int ti);
int main() {
#ifdef Yinku
freopen("Yinku.in","r",stdin);
//freopen("Yinku.out","w",stdout);
#endif // Yinku
int T=read();
for(int ti=1;ti<=T;ti++)
TestCase(ti);
}
/*--- ---*/
char p[60],c[60],p2[60],c2[60];
char t[256];
void TestCase(int ti) {
int n=read(),m=read();
scanf("%s%s%s",p,c,c2);
int rightshift=c[0]-p[0];
if(rightshift<0)
rightshift+=26;
for(int i=0;i<m;i++){
p2[i]=c2[i]-rightshift;
if(p2[i]<'A')
p2[i]+=26;
}
p2[m]='\0';
printf("Case #%d: ",ti);
puts(p2);
}
Codeforces - 102222C - Caesar Cipher的更多相关文章
- 2018 ACM-ICPC 宁夏 C.Caesar Cipher(模拟)
In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward ...
- Codeforces gym102222 C. Caesar Cipher 签到
题意: 给定一对用凯撒密码加密的明文和密文,再给你一个密文,让你解密出明文,保证有唯一解. 题解: 对凯撒密码的已知明文攻击,签到题. #include<iostream> using n ...
- codeforces 722F - Cyclic Cipher
题目链接:http://codeforces.com/problemset/problem/722/F ------------------------------------------------ ...
- Caesar cipher
#include <iostream> using namespace std; int main() {int k,i; char s[5]; cin>>k; for(; ...
- [codeforces 901E] Cyclic Cipher 循环卷积-Bluestein's Algorithm
题目大意: 传送门 给两个数列${B_i}.{C_i}$,长度均为$n$,且${B_i}$循环移位线性无关,即不存在一组系数${X_i}$使得对于所有的$k$均有$\sum_{i=0}^{n-1} X ...
- CodeForces - 156C:Cipher (不错的DP)
Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But t ...
- The 2018 ACM-ICPC Chinese Collegiate Programming Contest Caesar Cipher
#include <iostream> #include <cstdio> #include <cstring> #include <string> # ...
- 凯撒密码(Caesar cipher) 详解
------------恢复内容开始------------ 最近训练CTF的时候,发现密码学这块的知识不太系统,所以自己接下来会陆陆续续整理出来 就先从古典密码中的凯撒密码说起吧 凯撒密码内容比较简 ...
- freeCodeCamp:Caesars Cipher
让上帝的归上帝,凯撒的归凯撒. 下面我们来介绍风靡全球的凯撒密码Caesar cipher,又叫移位密码. 移位密码也就是密码中的字母会按照指定的数量来做移位. 一个常见的案例就是ROT13密码,字母 ...
随机推荐
- npm-install once
Once 是我最习惯的模块,它展示了几乎所有的我书写的通过issac Schlueter创建的应用. 原理很简单,Once使用各类一个函数且返回了一个函数,你可以调用这个函数,但是只能调用一次.如果你 ...
- Struts2 第一个入门小案例
1.加载类库 2 配置web.xml文件 3.开发视图层 4.开发控制层Action 5.配置struts.xml 6.部署运行
- Appium-关于appium的原生控件的 xpath 定位问题及常用方法
最近遇到的项目,发现很多元素,都没有标明id.text.content-desc,classname中又有很多是相同,导致无法定位 第一,appium1.5及之后的版本废弃了name属性(如name= ...
- 浏览器对应的selenium版本问题
在selenium+python环境下查看selenium版本方法: cmd下输入:pip show selenium 卸载selenium版本: cmd下输入:pip uninstall selen ...
- 理解SetCapture()和ReleaseCapture()及GetCapture()作用
正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪,鼠标消息都发给指定的这个窗口,直到调用ReleaseCapture或者调用S ...
- cocos2d-x 中 xml 文件读取
实现类 CXmlParse 啥也不说了 直接上硬货 believe yourself 一看就明白 CXmlParse.h #ifndef __C_XML_PARSE__ #define __C ...
- C语言小程序(八)、统计字母个数
这么简单的程序本不应贴在这里,但每写一篇博客,积分涨10分,距离摆脱千里之外的排名又进一步,相当于刷榜了,哈哈! #include <stdio.h> #include <strin ...
- freeMarker(四)——模板开发指南之模板
学习笔记,选自freeMarker中文文档,译自 Email: ddekany at users.sourceforge.net 模板开发指南之模板 1. 总体结构 实际上用程序语言编写的程序就是模板 ...
- android SDK manager 无法获取更新版本列表【转载】
http://mirrors.neusoft.edu.cn/eclipse/releases/luna/打开这个网址就可以看到adt的详细信息: http://developer.android.c ...
- 搞事情 -- python之线程
简介 操作系统线程理论 线程概念的引入背景 线程的特点 进程和线程的关系 使用线程的实际场景 用户级线程和内核级线程(了解) 线程和python 理论知识 线程的创建Threading.Thread类 ...