space=1&num=1404">1404. Easy to Hack!

Time limit: 1.0 second

Memory limit: 64 MB
When Vito Maretti writes an important letter he encrypts it. His method is not very reliable but it’s enough to make any detective understand nothing in that letter. Sheriff doesn’t like such state of affairs. He wants to hack
the cipher of Vito Maretti and he promises to forget about all of your faults if you do that for him. Detectives will tell you what this cipher looks like.
Each word is enciphered separately. Assume an example that consists only of the small Latin letters.
At first step every letter is replaced with the corresponding number:
a with 0, b with 1,
c with 2, ..., z with
25
.Then 5 is added to the first number, the first number is added to the second one, the second number – to the third one and so on. After that if some number exceeds 25 it is replaced with the residue of division of this number by 26. And then those
numbers are replaced back with the letters.
Let’s encipher the word secret.

Step 0.   s   e   c   r   e   t
Step 1. 18 4 2 17 4 19
Step 2. 23 27 29 46 50 69
Step 3. 23 1 3 20 24 17
Step 4. x b d u y r
We’ve got the word xbduyr.

Input

You are given an encrypted word of small Latin letters not longer than 100 characters.

Output

the original word.

Sample

input output
xbduyr
secret

Problem Author: Vladimir Yakovlev

Problem Source: The 12th High School Pupils Collegiate Programming Contest of the Sverdlovsk Region (October 15, 2005)

解析:直接按题意模拟就可以。

AC代码:

#include <bits/stdc++.h>
using namespace std; int a[102]; int main(){
string s;
while(cin>>s){
int n = s.size();
for(int i=0; i<n; i++) a[i] = s[i] - 'a';
if(a[0] < 5) a[0] += 26;
for(int i=1; i<n; i++){
while(a[i] < a[i-1]) a[i] += 26;
}
for(int i=n-1; i>0; i--) a[i] -= a[i-1];
a[0] -= 5;
for(int i=0; i<n; i++) printf("%c", a[i] + 'a');
puts("");
}
return 0;
}

版权声明:本文sxk原创文章,转载本文,请添加链接!!!

URAL 1404. Easy to Hack! (模拟)的更多相关文章

  1. URAL 1069 Prufer Code(模拟)

    Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) ...

  2. URAL(timus) 1280 Topological Sorting(模拟)

    Topological Sorting Time limit: 1.0 secondMemory limit: 64 MB Michael wants to win the world champio ...

  3. Codeforces Round #547 (Div. 3) F1/2. Same Sum Blocks (Easy/Hard) (贪心,模拟)

    题意:有一长度为\(n\)的数组,求最多的区间和相同的不相交的区间的个数. 题解:我们可以先求一个前缀和,然后第一层循环遍历区间的右端点,第二层循环枚举左端点,用前缀和来\(O(1)\)求出区间和,\ ...

  4. Codeforces Round #653 (Div. 3) E1. Reading Books (easy version) (贪心,模拟)

    题意:有\(n\)本书,A和B都至少要从喜欢的书里面读\(k\)本书,如果一本书两人都喜欢的话,那么他们就可以一起读来节省时间,问最少多长时间两人都能够读完\(k\)本书. 题解:我们可以分\(3\) ...

  5. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  6. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  7. Unity3D插件分享

    网上看到一个讲unity3D插件的,看着不错,转载过来. 本文汇总了近百个Unity3D插件,供大家参考下载. 2D_Toolkit_1.51 动画开发插件包 FingerGestures 触摸插件 ...

  8. Unity3D 插件大全

    2D_Toolkit 2d动画开发插件包 FingerGestures 触摸插件 ORK_Okashi_RPG_Kit Unity3D角色扮演游戏开发工具包 uScript-Visual-Script ...

  9. Unity3D 200个插件免费分享

    插件清单: 2D_Toolkit_1.51     动画开发插件包 FingerGestures           触摸插件 ORK_Okashi_RPG_Kit       Unity3D角色扮演 ...

随机推荐

  1. Streak OpenCart 商城自适应主题模板 ABC-0010

    兼容浏览器 IE9, Firefox, Safari, Opera, Chrome OpenCart版本号 OpenCart 1.5.x, OpenCart 1.5.6.x, OpenCart 1.5 ...

  2. unity3d中让物体显示和隐藏

    unity3d中让物体显示和隐藏的方法 gameObject.renderer.enabled //是控制一个物体是否在屏幕上渲染或显示  而物体实际还是存在的 仅仅是想当于隐身 而物体本身的碰撞体还 ...

  3. Shuttle ESB(四)——宣布订阅模式实例介绍(1)

    前,我的重点是关注的三篇文章Shuttle ESB入境和宏观的概念范例. Shuttle ESB模式:请求/对应模式与Pub/Sub模式. 关于这两种模式的区分,请看以下文章的介绍:Shuttle E ...

  4. Java他们其中一个IO(一)

    1.I/O 操作的目标 其中从数据源读取数据,和写数据到的目标位置数据. 2.IO 的分类方法 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMTc ...

  5. yate.conf

    但档案.粘贴下面的例子.不解释!除去非常灵活!只保留sip电话! [general] ; General settings for the operation of Yate ; modload: b ...

  6. 数据库 版本号是 661,打不开。此server支持 655 和更早的版本号。不支持降级路径

    "数据库 的版本号为 661,无法打开.此server支持 655 版及更低版本号. 不支持降级路径" 出现这种问题,通常是由于数据库版本号不同造成的. 我们能够用以下的语句查询数 ...

  7. Spring 注解学习手札(七) 补遗——@ResponseBody,@RequestBody,@PathVariable (转)

    最近需要做些接口服务,服务协议定为JSON,为了整合在Spring中,一开始确实费了很大的劲,经朋友提醒才发现,SpringMVC已经强悍到如此地步,佩服! 相关参考: Spring 注解学习手札(一 ...

  8. HDU 4359 Easy Tree DP? 带权二叉树的构造方法 dp

    题意: 给定n deep 1.构造一个n个节点的带权树,且最大深度为deep,每一个节点最多仅仅能有2个儿子 2.每一个节点的值为2^0, 2^1 ··· 2^(n-1)  随意两个节点值不能同样 3 ...

  9. 第四章——SQLServer2008-2012资源及性能监控(3)

    原文:第四章--SQLServer2008-2012资源及性能监控(3) 本文为本系列最后一章,监控内存使用.监控服务器的内存是非常重要的事情,有很多情况会引起内存消耗.所以要经常性地做检查. 本文将 ...

  10. c#基于这些,你已经看到了?(一)-----谁才刚刚开始学习使用

    1.注视(不要写的目光是流氓,从废话名盲人) '///'一般用于目光功能.凝视类. 2.热键 ctrl+k+d(有语法错误无法进行对齐) ctrl+j(高速弹出仅仅能提示) shift+end,shi ...