Message Decowding

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 999    Accepted Submission(s): 468

Problem Description
The cows are thrilled because they've just learned about encrypting messages. They think they will be able to use secret messages to plot meetings with cows on other farms.

Cows are not known for their intelligence. Their encryption method is nothing like DES or BlowFish or any of those really good secret coding methods. No, they are using a simple substitution cipher.

The cows have a decryption key and a secret message. Help them decode it. The key looks like this:

yrwhsoujgcxqbativndfezmlpk

Which means that an 'a' in the secret message really means 'y'; a 'b' in the secret message really means 'r'; a 'c' decrypts to 'w'; and so on. Blanks are not encrypted; they are simply kept in place.

Input text is in upper or lower case, both decrypt using the same decryption key, keeping the appropriate case, of course.

 
Input
* Line 1: 26 lower case characters representing the decryption key

* Line 2: As many as 80 characters that are the message to be decoded

 
Output
* Line 1: A single line that is the decoded message. It should have the same length as the second line of input.
 
Sample Input
eydbkmiqugjxlvtzpnwohracsf
Kifq oua zarxa suar bti yaagrj fa xtfgrj
 
Sample Output
Jump the fence when you seeing me coming
 
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 1000
using namespace std;
int main()
{
char s[MAX];
char c;
while(scanf("%s",s)!=EOF)
{
getchar();
while(scanf("%c",&c)&&c!='\n')
{
if(c!=' ')
{
if(c>='A'&&c<='Z')
printf("%c",s[c-'A']-32);
else if(c>='a'&&c<='z')
printf("%c",s[c-'a']);
}
else
printf(" ");
}
printf("\n");
}
return 0;
}

  

hdu 2716 Message Decowding的更多相关文章

  1. OpenJudge / Poj 2141 Message Decowding

    1.链接地址: http://poj.org/problem?id=2141 http://bailian.openjudge.cn/practice/2141/ 2.题目: Message Deco ...

  2. hdu 4661 Message Passing(木DP&amp;组合数学)

    Message Passing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Other ...

  3. HDU 4661 Message Passing 【Tree】

    题意: 给一棵树,每一个结点都有一个信息,每一个时刻,某一对相邻的结点之间可以传递信息,那么存在一个最少的时间,使得所有的节点都可以拥有所有的信息.但是,题目不是求最短时间,而是求最短时间的情况下,有 ...

  4. HDU 4661 Message Passing ( 树DP + 推公式 )

    参考了: http://www.cnblogs.com/zhsl/archive/2013/08/10/3250755.html http://blog.csdn.net/chaobaimingtia ...

  5. 【 2013 Multi-University Training Contest 6 】

    HDU 4655 Cut Pieces 假设n个数构成的总数都分成了n段,总数是n*a1*a2*...*an.但是答案显然不会那么多. 对于相邻的两个ai,ai+1,如果选择相同的颜色,那么就减少了a ...

  6. 算法之路 level 01 problem set

    2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...

  7. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  8. Spring DI

    一.   Spring DI 依赖注入 利用spring IOC实例化了对象,而DI将实例化的对象注入到需要对象的地方,完成初始化任务. 对象由spring创建,之后再由spring给属性赋值 spr ...

  9. Eclipse 4.2 failed to start after TEE is installed

    ---------------  VM Arguments---------------  jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...

随机推荐

  1. spring事物的传播行为

    1.spring事物的传播行为,主要是用来解决业务层拥有事物的方法,相互调用的问题. 2.声明事物, 在代码执行前,开启事务.代码执行完,提交事务 3.spring并没有提供事务具体的处理,而只是调用 ...

  2. Android 自绘TextView解决提前换行问题,支持图文混排

    先看下效果图: 上面是MTextView,下面是默认的TextView. 一.原因 用最简单的全英文句子为例,如果有一个很长的单词,这一行剩余的空间显示不下了,那么规则就是不打断单词,而是把整个单词丢 ...

  3. 捕获Java线程池执行任务抛出的异常

    捕获Java线程池执行任务抛出的异常Java中线程执行的任务接口java.lang.Runnable 要求不抛出Checked异常, public interface Runnable { publi ...

  4. 超实用的PHP代码片段

    一.查看邮件是否已被阅读 当你在发送邮件时,你或许很想知道该邮件是否被对方已阅读.这里有段非常有趣的代码片段能够显示对方IP地址记录阅读的实际日期和时间. 1 2 3 4 5 6 7 8 9 10 1 ...

  5. cmd启动tomcat

    1.安装jdk 2.安装tomcat 3.需要配置两个用户环境变量,仅仅配置系统变量没用. a)JAVA_HOME:D:\programing~tools\java~tools\JDK(tm)\jdk ...

  6. FPGA中latency与delay概念的区别

    2013-06-17 21:09:26 最近学习流水线以及状态机,总遇到注入加入寄存器可以分割组合逻辑,从而提高电路的运行频率的说法:还有流水线可以提高速度的说法,刚开始很是疑惑,觉得流水线的方法,输 ...

  7. Use powerful plugins in your vim.

    # setup by root wget http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz tar -xzvf ctags-5.8.t ...

  8. Android 签名(8)签名前用Zipalign简单优化

    1 为什么要优化 Android SDK中包含一个“zipalign”的工具,它能够对打包的应用程序进行优化.在你的应用程序上运行zipalign,使得在运行时Android与应用程序间的交互更加有效 ...

  9. 摄像头(3)调用系统拍照activity来拍照

    import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager ...

  10. [信息OJ 2467] Asakura的难题

     2467: G Asakura的难题 Time Limit:2000MS Memory Limit:65536KB Description Asakura是班里有名的捣蛋鬼,所以经常有同学到老师那里 ...