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的更多相关文章

  1. 2018 ACM-ICPC 宁夏 C.Caesar Cipher(模拟)

    In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward ...

  2. Codeforces gym102222 C. Caesar Cipher 签到

    题意: 给定一对用凯撒密码加密的明文和密文,再给你一个密文,让你解密出明文,保证有唯一解. 题解: 对凯撒密码的已知明文攻击,签到题. #include<iostream> using n ...

  3. codeforces 722F - Cyclic Cipher

    题目链接:http://codeforces.com/problemset/problem/722/F ------------------------------------------------ ...

  4. Caesar cipher

    #include <iostream> using namespace std; int main() {int k,i; char s[5];  cin>>k;  for(; ...

  5. [codeforces 901E] Cyclic Cipher 循环卷积-Bluestein's Algorithm

    题目大意: 传送门 给两个数列${B_i}.{C_i}$,长度均为$n$,且${B_i}$循环移位线性无关,即不存在一组系数${X_i}$使得对于所有的$k$均有$\sum_{i=0}^{n-1} X ...

  6. CodeForces - 156C:Cipher (不错的DP)

    Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But t ...

  7. The 2018 ACM-ICPC Chinese Collegiate Programming Contest Caesar Cipher

    #include <iostream> #include <cstdio> #include <cstring> #include <string> # ...

  8. 凯撒密码(Caesar cipher) 详解

    ------------恢复内容开始------------ 最近训练CTF的时候,发现密码学这块的知识不太系统,所以自己接下来会陆陆续续整理出来 就先从古典密码中的凯撒密码说起吧 凯撒密码内容比较简 ...

  9. freeCodeCamp:Caesars Cipher

    让上帝的归上帝,凯撒的归凯撒. 下面我们来介绍风靡全球的凯撒密码Caesar cipher,又叫移位密码. 移位密码也就是密码中的字母会按照指定的数量来做移位. 一个常见的案例就是ROT13密码,字母 ...

随机推荐

  1. Spark- RDD持久化

    官方原文: RDD Persistence One of the most important capabilities in Spark is persisting (or caching) a d ...

  2. matlab产生很多个相同的数字

    如产生100行1列的0.5: ones(100,1)*0.5:

  3. Cuckoo hash算法分析——其根本思想和bloom filter一致 增加hash函数来解决碰撞 节省了空间但代价是查找次数增加

    基本思想: cuckoo hash是一种解决hash冲突的方法,其目的是使用简单的hash 函数来提高hash table的利用率,同时保证O(1)的查询时间 基本思想是使用2个hash函数来处理碰撞 ...

  4. windows 批处理ping ip

    //pingSingleIp ;;@Echo off @for /f "tokens=1-4 delims=." %%i in (ip.txt) do (@ping -w 600 ...

  5. 素数环:NYOJ--488--dfs||hdu-1016-Prime Ring Problem

    /* Name: NYOJ--488--素数环 Author: shen_渊 Date: 15/04/17 15:30 Description: DFS,素数打个表,37以内就够用了 */ #incl ...

  6. phpunit手动配置

    phpunit: #!D:\xampp\php\.\php.exe<?php/* PHPUnit * * Copyright (c) 2001-2013, Sebastian Bergmann ...

  7. BZOJ5461: [PKUWC2018]Minimax

    BZOJ5461: [PKUWC2018]Minimax https://lydsy.com/JudgeOnline/problem.php?id=5461 分析: 写出\(dp\)式子:$ f[x] ...

  8. poj3585 Accumulation Degree[树形DP换根]

    思路其实非常简单,借用一下最大流求法即可...默认以1为根时,$f[x]$表示以$x$为根的子树最大流.转移的话分两种情况,一种由叶子转移,一种由正常孩子转移,判断一下即可.换根的时候由頂向下递推转移 ...

  9. 洛谷【P1177】【模板】基数排序

    题目传送门:https://www.luogu.org/problemnew/show/P1177 我对计数排序的理解:https://www.cnblogs.com/AKMer/p/9649032. ...

  10. 批量清除过期的binlog释放磁盘空间

    方案,总共24台db,一台台进去清理肯定不行,得需要写一个脚本,进行批量操作,方案思路大概如下 1,  建立双master列表masterlist; 一个master一行. 2,远程获取master ...