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密码,字母 ...
随机推荐
- python的字符串操作函数之一览
s.strip(chars) s.find(x,start,end) s.index(x.start,end)#见上: s.format()#见上: s.partition(x)#见上: s.repl ...
- BZOJ 3433 [Usaco2014 Jan]Recording the Moolympics:贪心
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3433 题意: 给出n个区间[a,b). 有两个记录器,每个记录器中存放的区间不能重叠. 求 ...
- php 简单笔记
1.时间 $date1 = "2014-11-11"; echo date('Y-m-d',strtotime("$date1 +5 day")); //输出结 ...
- 十大最流行PHP框架排名
PHP 是一个被广泛使用的来进行Web开发的脚本语言.虽然有很多其它可供选择的Web开发语言,像:ASP 和Ruby,但是PHP是目前为止世界上最为流行的. 那么,是什么让PHP如此流行?PHP 如此 ...
- css绝对对齐
方法1:使用text-align:justify 能够兼容所有的浏览器,但是一定要在模块和模块或者字之间存在空格,换行符或者制表符,这样才能起作用 ;;} /* 说明: 1.IE中要实现块内单行两端对 ...
- mysql基本语句1
操作MySQL数据库 向表中插入数据 insert 语句可以用来将一行或多行数据插到数据库表中, 使用的一般形式如下: insert [into] 表名 [(列名1, 列名2, 列名3, ...)] ...
- 【LeetCode】014. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 题解: 简单的暴力遍历解决 ...
- iOS+PHP图片上传
这篇博客用于实现iOS客户端通过POST请求,将图片上传到服务器上.服务器端语言采用PHP,服务器环境使用MAMP搭建.先使用浏览器测试图片是否可以上传,浏览器测试成功之后再测试iOS客户端是否可以成 ...
- [IBM]掌握Ajax,Ajax中的高级请求和响应
掌握 Ajax, Ajax 中的高级请求和响应 http://www.ibm.com/developerworks/cn/xml/wa-ajaxintro1.html http://www.ibm.c ...
- Azure上部署FTP服务
FTP是个比较复杂的协议,其协议分为控制层和数据层,工作模式分为主动和被动两种模式. 在默认的Active模式下其工作原理如下: 可以看到,客户端发起FTP的请求道服务器端,FTP的端口是21.用户在 ...