一、Description

Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly
sound, that no one could figure it out without knowing how it worked.

You are a sub captain of Caesar's army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each letter in a plaintext message, you shift it five places to the right to create the secure message (i.e.,
if the letter is 'A', the cipher text would be 'F'). Since you are creating plain text out of Caesar's messages, you will do the opposite:

Cipher text

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Plain text

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

Only letters are shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters will be upper case.

Input

Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. All characters will
be uppercase.

A single data set has 3 components

  1. Start line - A single line, "START"
  2. Cipher message - A single line containing from one to two hundred characters, inclusive, comprising a single message from Caesar
  3. End line - A single line, "END"

Following the final data set will be a single line, "ENDOFINPUT".

Output

For each data set, there will be exactly one line of output. This is the original message by Caesar.

二、问题分析

        最近两天,哥们被三伏天折磨的想死的心都有了。于是乎,我决定找几道水题来降降温。这道号称是“史上最难的问题”的题目就是一道标准的水题。

        题目很简单,密码转译问题。开始的时候以为是加密,这也算是我所唯一检查了的地方。用字符串存放输入,然后把字符串转换为字符数组。把字母分为两部分,A~F字符转换为Ascii码后加21,G~Z转换为AscII后减5。遍历每个字符,按上面的规则改变字母。

        刚刚看到网友爆料,此题居然和3749一样。我还以为是和它一样水呢,没想到是一样的题,不过3749是中文的。哎呀,还省了翻译的时间,要知道水题最难之处就是翻译啊!!!

三、Java代码

     
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException {
BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
while(!read.readLine().equals("ENDOFINPUT")){
String s=read.readLine();
char[] c=s.toCharArray();
for(int i=0;i<c.length;i++){
int a=(int)c[i];
if(a>= 70 && a<=90){
c[i]=(char) (c[i]-5);
}else if(a>=65 && a<=69){
c[i]=(char) (c[i]+21);
}
}
System.out.println(c);
read.readLine();
}
}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Poj1298_The Hardest Problem Ever(水题)的更多相关文章

  1. fzuoj Problem 2182 水题

    http://acm.fzu.edu.cn/problem.php?pid=2182 Problem 2182 水题 Accept: 188    Submit: 277Time Limit: 100 ...

  2. 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem A: The 3n + 1 problem(水题)

    Problem A: The 3n + 1 problem Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 14  Solved: 6[Submit][St ...

  3. [POJ 1000] A+B Problem 经典水题 C++解题报告 JAVA解题报告

        A+B Problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 311263   Accepted: 1713 ...

  4. HDU 4716 A Computer Graphics Problem (水题)

    A Computer Graphics Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  5. poj1298 The Hardest Problem Ever 简单题

    链接:http://poj.org/problem?id=1298&lang=default&change=true 简单的入门题目也有这么强悍的技巧啊!! 书上面的代码: 很厉害有没 ...

  6. POJ1298_The Hardest Problem Ever_最难的问题_Caesar 密码_C++

    题目:http://poj.org/problem?id=1298 好吧,给了题目也看不懂……给出翻译(题目名翻译是:最难的问题,233333) 这一看就是老师给出题解: 然而没有什么用哈 最快的办法 ...

  7. HDOJ(HDU) 1898 Sempr == The Best Problem Solver?(水题、、、)

    Problem Description As is known to all, Sempr(Liangjing Wang) had solved more than 1400 problems on ...

  8. zzulioj--1634--Happy Thanksgiving Day - A + B Problem(模拟水题)

     1634: Happy Thanksgiving Day - A + B Problem Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 136  ...

  9. HDU 5443 The Water Problem (水题,暴力)

    题意:给定 n 个数,然后有 q 个询问,问你每个区间的最大值. 析:数据很小,直接暴力即可,不会超时,也可以用RMQ算法. 代码如下: #include <cstdio> #includ ...

随机推荐

  1. 九度OJ 1190:大整数排序 (大数运算、排序)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3219 解决:1467 题目描述: 对N个长度最长可达到1000的数进行排序. 输入: 输入第一行为一个整数N,(1<=N<=1 ...

  2. 京东android面试题(2018 顶级互联网公司面试题系列)

    以下来自于北京的一个兄弟的面试题 1.静态内部类和非静态内部类有什么区别  2.谈谈你对java多态的理解  3.如何开启线程,run和runnable有什么区别  4.线程池的好处  5.说一下你知 ...

  3. PAT 1051. 复数乘法 (15)

    复数可以写成(A + Bi)的常规形式,其中A是实部,B是虚部,i是虚数单位,满足i2 = -1:也可以写成极坐标下的指数形式(R*e(Pi)),其中R是复数模,P是辐角,i是虚数单位,其等价于三角形 ...

  4. Excel控制IE

    ---恢复内容开始--- 1.初始化and连接http网页 Set ie = CreateObject("InternetExplorer.Application") ie.Vis ...

  5. [转]eclipse中的常用快捷键

    1.选中你要加注释的区域,用ctrl+shift+C 会加上//注释2.先把你要注释的东西选中,用shit+ctrl+/ 会加上注释3.要修改在eclispe中的命令的快捷键方式我们只需进入windo ...

  6. Android系统篇之—-编写系统服务并且将其编译到系统源码中【转】

    本文转载自:http://www.wjdiankong.cn/android%E7%B3%BB%E7%BB%9F%E7%AF%87%E4%B9%8B-%E7%BC%96%E5%86%99%E7%B3% ...

  7. Ubuntu dpkg 查询已安装的软件包

    要检查特定的包,比如firefox是否安装了,使用这个命令: dpkg -s firefox 要列出你系统中安装的所有包,输入下面的命令: dpkg --get-selections 你同样可以通过g ...

  8. 《python基础教程(第二版)》学习笔记 语句/循环/条件(第5章)

    <python基础教程(第二版)>学习笔记 语句/循环/条件(第5章) print 'AB', 123 ==> AB 123 # 插入了一个空格print 'AB', 'CD' == ...

  9. 【转】BNF和EBNF的含义与用法

    [转]BNF和EBNF的含义与用法   BNF 和EBNF的含义与用法 1简介       关于本文       什么是BNF?工作原理       基本原理       一个实例 EBNF及其用途  ...

  10. Java -- AWT 菜单建立, Menu, 右键菜单

    1. Menu类结构 2. 菜单示例:  MenuBar容器中可以装Menu,Menu容器中可以装MenuItem. public class SimpleMenu { Frame f = new F ...