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. Eclipse——热键&amp;Help

    版权声明:本文博主原创文章.博客,未经同意不得转载.

  2. [原创].NET 分布式架构开发实战之四 构建从理想和实现之间的桥梁(前篇)

    原文:[原创].NET 分布式架构开发实战之四 构建从理想和实现之间的桥梁(前篇) .NET 分布式架构开发实战之四 构建从理想和实现之间的桥梁(前篇) 前言:上一篇文章讲述了一些实现DAL的理论,本 ...

  3. 在SSMS里查看TDS数据包内容

    原文:在SSMS里查看TDS数据包内容 在SSMS里查看TDS数据包内容 摘抄自<SQLSERVER2012实施与管理实战指南> 要具体查看TDS数据库的内容,我们可以: 用NETWORK ...

  4. POJ3581:Sequence(后缀数组)

    Description Given a sequence, {A1, A2, ..., An} which is guaranteed A1 > A2, ..., An,  you are to ...

  5. 使用SQLServer 2008的CDC功能实现数据变更捕获

    原文:使用SQLServer 2008的CDC功能实现数据变更捕获 最近由于工作需要,研究了一下2008 CDC功能,觉得还不错,下面整理了一下研究过程,虽然比较粗略,但是基本上能用了,如果有补充请大 ...

  6. Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-30 @author: guaguastd @name: f ...

  7. poj 1664 把平果

    这个问题可分为两个子问题:什么时候m<n时刻,例如3苹果放在4阿菜,和3苹果放3一样的. 所以m<n时,f[m][n]=f[m][m]; 当m>=n时.可分为两种放法,一种为至少有一 ...

  8. SQLHlper意识

    经过学习,通过线敲登录的三个例子,敲四行CRUD样品,因此,访问数据库多次,在这些链接库.打开都一样.只是不同的操作将针对不同的表进行.始学习面向对象的思想.当让要对这些不变的要内容要进行打包,提高代 ...

  9. js Array 阵列扩展方法

    //又来了 Array.prototype.unique = function() { this.sort(); var re=[this[0]]; for(var i = 1; i < thi ...

  10. 接口设计ie常见的问题

    问题叙述性说明: 当围绕一个简单的页面布局设计.我发现了一个奇怪的相对布局问题. 同的方式围绕布局接口.它是利用左div浮动.对div设定 margin-left这样达到的效果.实现了chrome浏览 ...