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. 创建Material Design风格Android应用--自定义阴影和裁剪视图

    之前已经写过通过应用主题和使用ListView, CardView,应用Material Design样式,同一时候都都能够通过support library向下兼容.今天要写的阴影和视图裁剪.无法向 ...

  2. 希尔排序----java实现

    思路:希尔排序是分组基础上的直接插入排序,给定的一个步长数组,每个小组先直接插入排序.虽然有四次循环,但是每次循环次数少. package com.sheepmu.text; import java. ...

  3. quick-cocos2d-x endToLua 退出会卡住

    问题: 马上赚钱,退出会出现卡住,然后清理,死界面的情况,百思不得其解,昨天在做push的时候,突然发现.在android里面弹出一个退出对话框,点击确定退出,这时候调用endtolua时,有时也会切 ...

  4. NET5 Web应用程序

    ASP.NET5 Web应用程序结构 本文参考ASP.NET5 官方文档 Understanding ASP.NET 5 Web Apps,加入了一些个人理解,理解不对的地方希望大家能指出,互相学习. ...

  5. Android - 用Fragments实现动态UI - 使用Android Support Library

    Android Support Library提供了一个带有API库的JAR文件来让你可以在使用最新的Android API的同时也也已在早期版本的Android上运行.例如,Support Libr ...

  6. Android-管理Activity生命周期

    用户在浏览,退出,返回app时,app中的Activity实例会在不同状态之间切换.比如,当activity第一次启动,然后来到系统前台,受到用户的注意,这个过程中,android系统调用了一系列ac ...

  7. Spring.Net控制翻转、依赖注入、面向切面编程

    Spring.Net快速入门:控制翻转.依赖注入.面向切面编程 Spring.Net主要功能: 1.IoC:控制翻转(Inversion of Control)  理解成抽象工厂翻转控制:就是创建对象 ...

  8. expandableListView的divider该溶液显示在黑色

    黑色是divider高度.如何让他成为透明的啊? 布局例如以下:   <ExpandableListView android:layout_width="wrap_content&qu ...

  9. Android View系统解析(上)

  10. HDOJ 4745 Two Rabbits DP

    Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Tot ...