URAL 1404. Easy to Hack! (模拟)
space=1&num=1404">1404. Easy to Hack!
Memory limit: 64 MB
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.
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.
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
Input
Output
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! (模拟)的更多相关文章
- URAL 1069 Prufer Code(模拟)
Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) ...
- URAL(timus) 1280 Topological Sorting(模拟)
Topological Sorting Time limit: 1.0 secondMemory limit: 64 MB Michael wants to win the world champio ...
- Codeforces Round #547 (Div. 3) F1/2. Same Sum Blocks (Easy/Hard) (贪心,模拟)
题意:有一长度为\(n\)的数组,求最多的区间和相同的不相交的区间的个数. 题解:我们可以先求一个前缀和,然后第一层循环遍历区间的右端点,第二层循环枚举左端点,用前缀和来\(O(1)\)求出区间和,\ ...
- Codeforces Round #653 (Div. 3) E1. Reading Books (easy version) (贪心,模拟)
题意:有\(n\)本书,A和B都至少要从喜欢的书里面读\(k\)本书,如果一本书两人都喜欢的话,那么他们就可以一起读来节省时间,问最少多长时间两人都能够读完\(k\)本书. 题解:我们可以分\(3\) ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- Unity3D插件分享
网上看到一个讲unity3D插件的,看着不错,转载过来. 本文汇总了近百个Unity3D插件,供大家参考下载. 2D_Toolkit_1.51 动画开发插件包 FingerGestures 触摸插件 ...
- Unity3D 插件大全
2D_Toolkit 2d动画开发插件包 FingerGestures 触摸插件 ORK_Okashi_RPG_Kit Unity3D角色扮演游戏开发工具包 uScript-Visual-Script ...
- Unity3D 200个插件免费分享
插件清单: 2D_Toolkit_1.51 动画开发插件包 FingerGestures 触摸插件 ORK_Okashi_RPG_Kit Unity3D角色扮演 ...
随机推荐
- jQuery Validate插入 reomte使用详细的说明
在用户注冊时常常要通过ajax请求推断用户账号是否已注冊,最方便的方法便是用jQuery Validate插件 reomte方法 Jquery Validate插件, 调用远程方法验证參数, remo ...
- [LeetCode235]Lowest Common Ancestor of a Binary Search Tree
题目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in th ...
- JList用法小结
JList用法小结 分类: JAVA技术2007-08-11 01:02 18485人阅读 评论(11) 收藏 举报 stringvectorclassjavaactionobject ...
- C# HttpClient Cookie验证解决方法
自实现的cookie 验证,远程取值的例子 以下代码配合HttpClient使用可以实现跨域(cookie的读写) //验证 复制代码 代码如下: HttpClient httpClient = ne ...
- 【Android进阶】SlidingMenu实现侧滑栏效果的实现
public class MainActivity extends Activity { @Override protected void onCreate(final Bundle savedIns ...
- C#设计及其UML(反向工程)
OOP之C#设计及其UML(反向工程) 现在总结一下C#类关键字(virtual.abstract.override.new.sealed)的使用(以C#代码体现),并再次熟悉一下OOP思想,使用 ...
- TextView于getCompoundDrawables()使用演示样本的方法
MainActivity例如下列: package cc.testcompounddrawables; import android.app.Activity; import android.grap ...
- [LeetCode] Combinations [38]
称号 Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exa ...
- Android提高第二篇之SurfaceView的基本使用
本文来自http://blog.csdn.net/hellogv/ ,引用必须注明出处! 上次介绍MediaPlayer的时候略微介绍了SurfaceView,SurfaceView因为能够直接从内存 ...
- 设计模式 State模式 机器的情况下用自己的主动性
转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/26350617 状态模型给我眼前一亮的感觉啊,值得学习~ 看看定义:改变一个对象的 ...