2145: 悄悄话

Time Limit: 10 Sec  Memory Limit: 259 MB
Submit: 271  Solved: 104
[Submit][Status][Discuss]

Description

在这个有话不直说的年代,密码学越来越被广泛接受。我们引用经典的“凯撒密码”。在英文中,凯撒加密只对26个字母生效(分大小写)我们按照a到z来排字母。凯撒加密的原理就是把原文的每一个字母都按顺序往后移K位。这个K将被作为密钥。(’a’往后移变成’b’,’z’往后移会变成’a’) (0< = K< = 25)现在给出一系列用凯撒加密的英文句子,请你编写程序逐句翻译。也就是说,请你确定一个密钥,使得解码以后的文字最符合英文的规则与规范。数据保证存在唯一的解码方案,使得明码是完全可以分辨的英文句子。

Input

输入一定包括10行每一行都是用同一密钥加密的英文。

Output

输出10行,为解密结果。不允许格式上有任何不同。

Sample Input

Welcome to the test. This is the 1st sample test case.
Vdkbnld sn sgd sdrs. Sghr hr sgd 2mc rzlokd sdrs bzrd.
Welcome to the test. This is the 3rd sample test case.
Nvctfdv kf kyv kvjk. Kyzj zj kyv 4ky jrdgcv kvjk trjv.
Govmywo dy dro docd. Drsc sc dro 5dr ckwzvo docd mkco.
Nvctfdv kf kyv kvjk. Kyzj zj kyv 6ky jrdgcv kvjk trjv.
Jrypbzr gb gur grfg. Guvf vf gur 7gu fnzcyr grfg pnfr.
Ucjamkc rm rfc rcqr. Rfgq gq rfc 8rf qyknjc rcqr ayqc.
Ckriusk zu znk zkyz. Znoy oy znk 9zn ygsvrk zkyz igyk.
Xfmdpnf up uif uftu. Uijt jt uif mbtu tbnqmf uftu dbtf.

Sample Output

Welcome to the test. This is the 1st sample test case.
Welcome to the test. This is the 2nd sample test case.
Welcome to the test. This is the 3rd sample test case.
Welcome to the test. This is the 4th sample test case.
Welcome to the test. This is the 5th sample test case.
Welcome to the test. This is the 6th sample test case.
Welcome to the test. This is the 7th sample test case.
Welcome to the test. This is the 8th sample test case.
Welcome to the test. This is the 9th sample test case.
Welcome to the test. This is the last sample test case.
【数据说明】
数据将从不同的方面考察。请尽量保证程序的准确性。
每一行长度不会太短(不少于3个单词的完整句)。没有全角字符和其他语言符号,可能包含半角空格和标点。
单个测试点不超过5kB。

HINT

 
 #include<cstdio>
#include<cstring>
#include<string>
std::string tmp,dict[]={"a","i","am","an","as","at","be","by","do","go","he","if","in","is","it","ll","me","mr","my","no","of","on","or","re","so","to","up","ve","we","ago","all","and","any","are","bar","bat","big","bit","boy","bug","but","can","cat","cup","cut","day","did","dog","don","end","fee","fly","for","fox","fur","get","gnu","god","gpl","had","has","her","him","his","how","iee","iel","its","joy","key","law","let","may","mrs","new","nor","not","now","one","our","out","paw","pay","ran","run","sat","saw","see","set","she","six","tea","the","too","two","use","war","was","way","who","why","yet","you","zoo","adam","also","aren","away","back","bank","bear","beat","beef","been","bell","bill","bird","boar","body","bone","book","bore","both","came","camp","case","code","come","cook","copy","damn","damp","date","dead","deer","deny","dish","does","dull","each","ever","eyes","face","felt","fill","find","fire","fish","five","four","free","from","gain","gave","gets","girl","give","glad","good","hand","hard","have","here","high","hold","hour","hunt","ieee","into","jack","just","keep","kept","kiss","knew","know","lamb","last","lazy","lead","left","lend","life","like","live","long","look","love","made","make","many","mars","mary","meat","meet","mind","mine","moon","moor","more","morn","most","much","must","name","need","nine","once","only","over","paid","pain","papa","pass","past","pays","pink","play","poor","pray","puma","rain","ramp","rope","said","sake","same","seen","shed","show","sing","some","song","stop","such","sure","take","tape","tell","than","that","them","then","they","this","tied","time","tiny","told","tony","took","tree","trip","true","upon","used","user","very","wall","want","wasn","ways","well","went","were","what","when","whom","wife","wild","will","wish","with","wood","work","year","your","about","added","adore","after","again","aleko","along","among","apple","apply","armed","asked","began","being","below","betty","black","blade","bleed","blood","bored","brown","carry","catch","cause","chuck","clock","comes","could","death","doesn","doing","dwelt","eight","every","facts","fetch","field","fifty","first","forty","found","fully","given","gives","going","grant","great","hands","happy","hares","heart","hours","human","jumps","keeps","kinds","known","lamps","large","legal","lines","lived","local","lover","lovin","madam","makes","marks","merry","miles","money","moses","names","never","night","offer","often","other","paint","parts","place","plain","plays","price","prize","prove","pumas","quick","quiet","reach","right","roses","scamp","seven","shall","share","shine","sight","since","sixty","small","sorry","south","speak","stars","start","steel","steps","still","sword","table","taken","teeth","terms","thank","theft","their","there","these","thief","thing","think","those","three","times","today","torch","tower","trade","trail","truly","trust","under","users","vicar","wants","watch","weeks","where","which","while","white","whole","wings","woken","woman","words","works","world","worth","would","yards","years","yours"};
char s[],s0[],s1[];int ii=,i,j,k,l,ans,now,key;
int inmap(){
for(int i=;i<;i++)if(tmp==dict[i])return ;
return ;
}
int check(int key){
int f=;memset(s0,,sizeof(s0));
for(j=;s[j];j++)
if(s[j]>='A'&&s[j]<='Z')s0[j]=s[j]-'A'+'a';
else s0[j]=s[j];
for(j=;s0[j];j++)if(s0[j]>='a'&&s0[j]<='z')s0[j]=(s0[j]-'a'+key)%+'a';
for(j=;s0[j];j++)
if(s0[j]>='a'&&s0[j]<='z'){
for(tmp="",k=j,l=;s0[k]&&s0[k]>='a'&&s0[k]<='z';k++)tmp+=s0[k];
if(inmap())f++;j=k-;
}
return f;
}
int main(){
//freopen("sh.txt","r",stdin);
for(int k;gets(s);puts(s)){
for(ans=,k=;k<;k++)if((now=check(k))>ans)ans=now,key=k;
for(i=;s[i];i++)
if(s[i]>='a'&&s[i]<='z')s[i]=(s[i]-'a'+key)%+'a';
else if(s[i]>='A'&&s[i]<='Z')s[i]=(s[i]-'A'+key)%+'A';
}
}

HYSBZ 2145 悄悄话的更多相关文章

  1. BZOJ 2145: 悄悄话 (打表)

    BZOJ 2145 题解 直接代词,所有格,常用副词,助动词,冠词,常用词打表 比较出现次数的多少来决定循环位移了几位. CODE #include <bits/stdc++.h> usi ...

  2. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  3. 协议森林17 我和你的悄悄话 (SSL/TLS协议)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 转载请先与我联系. TLS名为传输层安全协议(Transport Layer Protocol),这个协议是一套加密的 ...

  4. HYSBZ 2038 莫队算法

    小Z的袜子(hose) Time Limit:20000MS     Memory Limit:265216KB     64bit IO Format:%lld & %llu Submit  ...

  5. HDU 3966 & POJ 3237 & HYSBZ 2243 树链剖分

    树链剖分是一个很固定的套路 一般用来解决树上两点之间的路径更改与查询 思想是将一棵树分成不想交的几条链 并且由于dfs的顺序性 给每条链上的点或边标的号必定是连着的 那么每两个点之间的路径都可以拆成几 ...

  6. HYSBZ 2243

    //Accepted 18440 KB 5556 ms /* source:HYSBZ 2243 time :2015.5.29 by :songt */ /*题解: 树链剖分 */ #include ...

  7. CJOJ 1331 【HNOI2011】数学作业 / Luogu 3216 【HNOI2011】数学作业 / HYSBZ 2326 数学作业(递推,矩阵)

    CJOJ 1331 [HNOI2011]数学作业 / Luogu 3216 [HNOI2011]数学作业 / HYSBZ 2326 数学作业(递推,矩阵) Description 小 C 数学成绩优异 ...

  8. 2020考研-必须了解的干货"极限微分和你说的悄悄话"

    极限微分和你说的悄悄话 2019-03-02 RunWsh 美食供应商有考研学子 想必接触过数学或物理的都对牛顿和莱布尼兹不陌生.如果你是考研大军中的一员,估计天天会与他们眉来眼去的吧! 牛顿莱布:别 ...

  9. 【LOJ 2145】「SHOI2017」分手是祝愿

    LOJ 2145 100pts 这题...BT啊 首先我们很容易想出\(dp(msk)\)表示现在灯开关的情况是\(msk\),期望通过多少步走到终结态. 很明显\(dp(msk)=\frac{1}{ ...

随机推荐

  1. cl_gui_cfw=>dispatch

    将已经触发的EVENT发送给他们各自的EVENT HANDLER,以便让这些事件得到响应. 根据返回值可以判断是否发送成功. CALL METHOD cl_gui_cfw=>dispatch   ...

  2. SAP RFC通信模式

    在网络技术中,数据通信可以大致划分为两种基本模式:同步通信和异步通信. 其本义是:异步通信时,通信双方时钟允许存在一定误差:同步通信时,双方时钟的允许误差较小.在SAP的系统间的通信过程中,也借用术语 ...

  3. AE用线来分割线面(C#2010+AE10.0… .

    希望指正. 在 ITools 类中,部分方法如下: public override void OnMouseDown(int Button, int Shift, int X, int Y) { if ...

  4. 2015年第8本(英文第7本):the city of ember 微光城市

    书名:the City of Ember(中文名:微光城市) 作者:Jeanne DuPrau 单词数:6.2万 不重复单词数:未知 首万词不重复单词数:未知 蓝思值:未知 阅读时间:2015年4月2 ...

  5. 安卓开发_浅谈ListView(SimpleAdapter数组适配器)

    安卓开发_浅谈ListView(ArrayAdapter数组适配器) 学习使用ListView组件和SimapleAdapter适配器实现一个带图标的ListView列表 总共3部分 一.MainAc ...

  6. iOS网络-01-NSURLRequest与NSURLConnection

    NSURLRequest NSURLRequest封装了一次网络请求所需要的数据,主要封装了以下信息: 请求路径(URL) 请求方法(GET或POST) 请求头 请求体 超时参数 NSURLReque ...

  7. paas架构之docker——安装

    1. 概要 本文描述docker的安装 参考官方文档:https://docs.docker.com/engine/installation/linux/ubuntulinux/ 安装操作系统: Ub ...

  8. 《笨办法学python第三版》习题26,原错误代码及正确代码

    #import ex25 1 def break_words(stuff): """This function will break up words for us.&q ...

  9. SAM4E单片机之旅——20、DMAC之使用Multi-buffer进行内存拷贝

    这次使用这个DMAC的Multi-buffer传输功能,将两个缓冲区的内容拷贝至一个连续的缓冲区中. 一. DMAC 在M4中,DMA控制器(DMAC)比外设DMA控制器(PDC)要复杂,但是功能更加 ...

  10. echo

    echo $echo [-e] [内容字符串]显示后面的内容,缺省选项表示将后面的内容原模原样的显示出来,如果后面接的字符串不用"",会默认以空格为分隔符输出多个串 可以配合She ...