HYSBZ 2145 悄悄话
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
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 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 悄悄话的更多相关文章
- BZOJ 2145: 悄悄话 (打表)
BZOJ 2145 题解 直接代词,所有格,常用副词,助动词,冠词,常用词打表 比较出现次数的多少来决定循环位移了几位. CODE #include <bits/stdc++.h> usi ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 协议森林17 我和你的悄悄话 (SSL/TLS协议)
作者:Vamei 出处:http://www.cnblogs.com/vamei 转载请先与我联系. TLS名为传输层安全协议(Transport Layer Protocol),这个协议是一套加密的 ...
- HYSBZ 2038 莫队算法
小Z的袜子(hose) Time Limit:20000MS Memory Limit:265216KB 64bit IO Format:%lld & %llu Submit ...
- HDU 3966 & POJ 3237 & HYSBZ 2243 树链剖分
树链剖分是一个很固定的套路 一般用来解决树上两点之间的路径更改与查询 思想是将一棵树分成不想交的几条链 并且由于dfs的顺序性 给每条链上的点或边标的号必定是连着的 那么每两个点之间的路径都可以拆成几 ...
- HYSBZ 2243
//Accepted 18440 KB 5556 ms /* source:HYSBZ 2243 time :2015.5.29 by :songt */ /*题解: 树链剖分 */ #include ...
- CJOJ 1331 【HNOI2011】数学作业 / Luogu 3216 【HNOI2011】数学作业 / HYSBZ 2326 数学作业(递推,矩阵)
CJOJ 1331 [HNOI2011]数学作业 / Luogu 3216 [HNOI2011]数学作业 / HYSBZ 2326 数学作业(递推,矩阵) Description 小 C 数学成绩优异 ...
- 2020考研-必须了解的干货"极限微分和你说的悄悄话"
极限微分和你说的悄悄话 2019-03-02 RunWsh 美食供应商有考研学子 想必接触过数学或物理的都对牛顿和莱布尼兹不陌生.如果你是考研大军中的一员,估计天天会与他们眉来眼去的吧! 牛顿莱布:别 ...
- 【LOJ 2145】「SHOI2017」分手是祝愿
LOJ 2145 100pts 这题...BT啊 首先我们很容易想出\(dp(msk)\)表示现在灯开关的情况是\(msk\),期望通过多少步走到终结态. 很明显\(dp(msk)=\frac{1}{ ...
随机推荐
- 移动端调试工具-Debuggap
随着移动互联网的迅速崛起,开发移动应用程序越来越多,但如果在移动端开发应用程序需要调试时,额- 仿佛又回到了IE时代,最方便也只能到处 alert 来调试.目前已经有一款产品可以做到这一点,比如pho ...
- SharePoint 2013 - User
1. 在SharePoint 2010中,可以搜索出NT AUTHORITY\authenticated users,但在SharePoint 2013中,不能搜索出,需要手动写入全名后进行验证: 2 ...
- MX4连接后adb无法识别解决方法
1. 使用android SDK目录中的 android SDK目录\tools 下的android脚本,命令行中执行 android update adb,成功运行后,会在用户名录下产生,C:\Us ...
- PL/SQL基础1(笔记)
--基本结构DECLARE--变量声明部分:在此声明PL/SQL用到的变量,类型,游标,以及局部的存储过程和函数BEGIN --执行部分:过程及SQL语句,即程序的主要部分 EXCEPTION --执 ...
- MacOs终端忽略大小写
使用MacOs的终端时,唯一让人感觉不爽的就是Tab补全是区分大小的,所以查了资料就把这个问题搞定了.在用户目录下创建 .inputrc 文件,内容为以下三行代码,保存后重启终端再次输入文件名Tab补 ...
- iOS:自己写的一个星级评价的小Demo
重新整理了下自己星级评价的Demo,可以展示星级评价,可以动态修改星级. github的地址:https://github.com/hunterCold/HYBStarEvaluationView a ...
- js 字符串转 数字
<html> <body> <script language="javascript"> var a = "0.11"; v ...
- 利用 cos 组件实现jsp中上传附件
需求:在web功能中附件上传功能为最基本的功能之一,所以用cos组件做了一个附件上传的demo.附件上传功能的实现可以利用其它的java组件实现,相关资料网上比较多. 说明步骤:下载组件并安装 --& ...
- ElasticSearch Filter Aggregations
类似于sql语句中where子句的作用 { "query": { "match_all": {} }, "aggs": { "ag ...
- location(未完)
参考博客 http://blog.csdn.net/wksnm0724/article/details/37872787 http://my.oschina.net/justdo/blog/11839 ...