URAL 1404. Easy to Hack! (模拟)
来源:互联网 发布:java 调用interface 编辑:程序博客网 时间:2024/05/17 19:14
1404. Easy to Hack!
Time limit: 1.0 second
Memory limit: 64 MB
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 tStep 1. 18 4 2 17 4 19Step 2. 23 27 29 46 50 69Step 3. 23 1 3 20 24 17Step 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
xbduyr
secretProblem 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;}
0 0
- URAL 1404. Easy to Hack! (模拟)
- Timus 1404. Easy to Hack! 有一个密码问题
- URAL 1319. Hotel (模拟)
- So Easy!!! (栈模拟)
- Android Run Time: An Easy Hack To Make Your Phone Faster And Its Battery Last Longer
- URAL 1037. Memory Management (模拟)
- URAL 1290. Sabotage(STL & 模拟啊)
- URAL 1893. A380(模拟啊 )
- URAL 1893. A380 (阅读理解 + 模拟)
- URAL 1712. Cipher Grille (模拟)
- ural 1889 Airport Announcements (暴力模拟)
- LeetCode-13-Roman to Integer(number/模拟)-Easy
- URAL 1044. Lucky tickets. Easy!
- ural 1044 Lucky Tickets. Easy!
- ZOJ 2969 Easy Task(模拟)
- UVALive-7470-Easy Problemset(模拟)
- HDU 2418 Another Easy Problem(模拟)
- ural 1149【模拟】
- 公司在千万级别数据上线项目上出现的问题 以及 相应需要注意的点
- 基于xilinx ise开发流程介绍
- oracle索引
- iOS之NSXMLParser对XML解析
- Git学习教程:[3]如何使用分支
- URAL 1404. Easy to Hack! (模拟)
- web前端面试常见问题三------浮动原理和清除浮动
- NSOperation 简单使用
- QTPtest中Action种类
- java自带定时器 ScheduledExecutor
- 操作系统知识汇总--进程与线程
- NGUI控件的一些说明——基于3.7.7版本
- Maven中央仓库信息速查 网址,java 源码下载地址
- 一、mdf文件如何导入到SQL-Server数据库