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角色扮演 ...
随机推荐
- UVA434 - Matty's Blocks
option=com_onlinejudge&Itemid=8&page=show_problem&category=457&problem=375&mosms ...
- 关于scope_identity()与 @@IDENTITY
原文:关于scope_identity()与 @@IDENTITY 参考:https://msdn.microsoft.com/zh-cn/library/ms190315.aspx scope_id ...
- Java线程学习笔记(两) 线程异常处理
线程捕获异常: 情况下,我们在main()方法里是捕捉不到线程的异常的,比例如以下面代码: public class ExceptionThread implements Runnable{ @Ove ...
- 深入浅出JMS(一)——JMS简要
假设手机只能实时通话.没有邮件和短信功能发生?一个电话回来.只是没有足够的时间去连接.然后传递这款手机的信息肯定是不接受. 么不能先将信息存下来.当用户须要查看信息的时候再去获得信息呢?伴随着这个疑惑 ...
- 从零开始做UI-静电的sketch设计教室 视频教程
全套31集目录 01-初识Sketch http://www.ui.cn/detail/52223.html02-sketch的下载与安装 http://www.ui.cn/detail/5222 ...
- [渣译文] SignalR 2.0 系列:SignalR的高频实时通讯
原文:[渣译文] SignalR 2.0 系列:SignalR的高频实时通讯 英文渣水平,大伙凑合着看吧…… 这是微软官方SignalR 2.0教程Getting Started with ASP.N ...
- Apple Watch 1.0 开发介绍 1.3 简介 WatchKit App 架构
WatchKit app和WatchKit extension一起实现了app的界面.当用户在Apple Watch中操作时,WatchKit app从storyboards中选择合适的场景.比如,如 ...
- Visual Studio 2015 中文企业版及专业版 正式版下载地址 激活秘钥 正版key
Visual Studio 简体中文企业版 2015 (x86 and x64)文件名 cn_visual_studio_enterprise_2015_x86_x64_dvd_6846222.iso ...
- ORACLE—002:Create创作型
--用于工作的积累SQL ORACLE另外还有的类型.储过程.函数等的输入输入出. 以下看下创建. 使用方法 CREATE OR REPLACE TYPE 类型名称 AS OBJECT( 字段1 ...
- StackExchange.Redis Client
StackExchange.Redis Client 这期我们来看StackExchange.Redis,这是redis 的.net客户端之一.Redis是一个开源的内存数据存储,可以用来做数据库,缓 ...