Timus 1404. Easy to Hack! 有一个密码问题
来源:互联网 发布:杰克琼斯淘宝客服 编辑:程序博客网 时间:2024/06/06 02:03
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
secret
原来简单的加密也不是什么难事。做了那么多加密题,我也可以随手写个加密器了。
本题就是一个字符串的操作, 考的是字符串和整形之间的转换操作:
本题注意:第一个字母小于f的时候,转换为整数就会小于5了。
#include <string>#include <vector>#include <cmath>#include <algorithm>#include <iostream>using namespace std;void EasytoHack1404(){string s;cin>>s;vector<int> tmp(s.size());for (int i = 0; i < s.size(); i++){tmp[i] = s[i] - 'a';}int t = tmp[0];tmp[0] -= 5;if (tmp[0] < 0) tmp[0] += 26;for (int i = 1; i < tmp.size(); i++){int a = tmp[i];tmp[i] -= t;if (tmp[i] < 0) tmp[i] += 26;t = a;}for (int i = 0; i < tmp.size(); i++){cout<<char(tmp[i]+'a');}}
1 0
- Timus 1404. Easy to Hack! 有一个密码问题
- URAL 1404. Easy to Hack! (模拟)
- Easy UI Combotree选中项样式问题的hack
- Android Run Time: An Easy Hack To Make Your Phone Faster And Its Battery Last Longer
- centos7密码被hack
- Timus 1654. Cipher Message 破解密码
- Timus - 1110. Power 除尽问题
- Beggining to Hack
- How to Hack Runescape
- how to hack
- Goodbye to CSS Hack
- Goodbye to CSS Hack
- [Hacking]How to hack
- CSS HACK TO ie
- How to Hack
- 有一个RAC问题
- 记住密码?so easy!
- Timus 2002. Test Task 一个登陆系统
- C++primer plus第六版课后编程题答案15.1
- Android Volley 之自定义Request
- cadence软件问题解决集
- Python核心编程第七章笔记
- leetcode之Best Time to Buy and Sell Stock III
- Timus 1404. Easy to Hack! 有一个密码问题
- 【转】Android开源项目汇总列表
- 词汇 1
- android中正确导入第三方jar包
- 【OpenCV入门教程之十一】 形态学图像处理(二):开运算、闭运算、形态学梯度、顶帽、黑帽合辑
- easyui checkbox tree使用心得
- CUDA学习(一)
- 计算机视觉领域的一些牛人博客,研究机构等的网站链接
- PHP基础学习第一讲(基本知识)