The Hardest Problem Ever

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1048

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31307    Accepted Submission(s):
14491

Problem 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:

Start line - A single line, "START"

Cipher message - A single
line containing from one to two hundred characters, inclusive, comprising a
single message from Caesar

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.
 
Sample Input
START
NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX
END
START
N BTZQI WFYMJW GJ KNWXY NS F QNYYQJ NGJWNFS ANQQFLJ YMFS XJHTSI NS WTRJ
END
START
IFSLJW PSTBX KZQQ BJQQ YMFY HFJXFW NX RTWJ IFSLJWTZX YMFS MJ
END
ENDOFINPUT
 
Sample Output
IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES
I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME
DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE
 
Source
 
可以用JAVA进行枚举。
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner inScanner = new Scanner(System.in);
while(inScanner.hasNext()) {
String string = inScanner.nextLine();
if(string.equals("ENDOFINPUT")) {
break;
}
else if(string.equals("START") || string.equals("END")) {
continue;
}
else {
for(int i = ;i<string.length();i++) {
if(string.charAt(i)>='A' && string.charAt(i)<='E') {
System.out.printf("%c",string.charAt(i)+-);
}
else if(string.charAt(i)>='F'&&string.charAt(i)<='Z'){
System.out.printf("%c", string.charAt(i)-);
}
else {
System.out.printf("%c",string.charAt(i));
}
}
}
System.out.println();
}
}
}

(字符串 枚举)The Hardest Problem Ever hdu1048的更多相关文章

  1. The Hardest Problem Ever(字符串)

    The Hardest Problem Ever Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24039   Accept ...

  2. HDUOJ-------The Hardest Problem Ever

    The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  3. hdu_1048_The Hardest Problem Ever_201311052052

    The Hardest Problem Ever Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  4. HDU1048The Hardest Problem Ever

    The Hardest Problem Ever Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

  5. POJ 1298 The Hardest Problem Ever【字符串】

    Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was ke ...

  6. Poj1298_The Hardest Problem Ever(水题)

    一.Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar eve ...

  7. poj1298 The Hardest Problem Ever 简单题

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

  8. HDOJ 1048 The Hardest Problem Ever(加密解密类)

    Problem Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caes ...

  9. C - The Hardest Problem Ever

    Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...

随机推荐

  1. 解决post、get端中文乱码问题

    在web.xml中配置: <filter> <filter-name>CharacterEncodingFilter</filter-name> <filte ...

  2. 定位linux jdk安装路径

    如何在一台Linux服务器上查找JDK的安装路径呢? 有那些方法可以查找定位JDK的安装路径?是否有一些局限性呢? 下面总结了一下如何查找JDK安装路径的方法. 1:echo $JAVA_HOME 使 ...

  3. hibernate多对多映射文件的配置

    user.hbm.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate ...

  4. js获取参数 解决乱码

    获取参数 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^& ...

  5. docker-安装技巧

    使用官方脚本安装 curl -fsSL "https://get.docker.com/" | sh 使用yum 安装是可以查看版本 yum list docker-ce.x86_ ...

  6. 欧拉筛法模板&&P3383 【模板】线性筛素数

    我们先来看欧拉筛法 •为什么叫欧拉筛呢?这可能是跟欧拉有关 •但是为什么叫线性筛呢?因为它的复杂度是线性的,也就是O(n),我们直接来看代码   #include<cstdio> #inc ...

  7. Django+Vue打造购物网站(一)

    环境搭建 python == 3.6 Django == 2.0 创建工程 django-admin startproject MxShop 配置setting.py文件 # 数据库 DATABASE ...

  8. TP5调用微信JSSDK 教程 - 测试成功案例

    前提:必需了解TP5的全局配置,扩展目录,composer,依赖注入的概念: 第一步:首先配置加载官方JSSDK类 "autoload": { "files": ...

  9. 【 HDU 1538 】A Puzzle for Pirates (海盗博弈论)

    BUPT2017 wintertraining(15) #5D HDU 1538 偷懒直接放个果壳的链接了,感觉比网上直接找这题的题解要更正确.易懂. 海盗博弈论 代码 #include <cs ...

  10. 天哪又要搬家啦qvq

    CSDN现在怎么这么好看了qvq 搬家回去的欲望日渐强烈... update:2019/02/25 被csdn的侧栏广告烦死了