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. Js 常用字符串操作 API

    常用的一些字符串操作 API 整理 1.str.charAt(index).str.charCodeAt(index) - 返回指定位置的字符 / 字符编码(0~65535) index - 必须,表 ...

  2. Coalesce (MS SQL Server)——取指定内容(列)中第一个不为空的值

    oalesce 获得参数中第一个不为空的表达式. 语法:        COALESCE ( expression [ ,...n ] ) 例子:CREATE TABLE wages          ...

  3. Detected problems with API compatibility(visit g.co/dev/appcompat for more info)

    应用开启了debug模式导致Android 9提示如此,使用release模式即可解决.

  4. 学习 Spring (五) Aware 接口

    Spring入门篇 学习笔记 Spring 中提供了一些以 Aware 结尾的接口,实现了 Aware 接口的 bean 在被初始化之后可以获取相应资源 通过 Aware 接口,可以对 Spring ...

  5. gauss——seidel迭代

    转载:https://blog.csdn.net/wangxiaojun911/article/details/6890282 Gauss–Seidelmethod 对应于形如Ax = b的方程(A为 ...

  6. hdu-3068(最长回文子串-manacher)

    题意:求一个字符串#include<iostream>#include<algorithm>#include<cstring>using namespace std ...

  7. Nginx 反向代理接收用户包体方式

    陶辉91课 如果proxy_request_buffering 设置为on的时候是等待nginx读取完包体后再发送上游服务器 一般依赖于nginx处理能力  client_body_in_file_o ...

  8. 【C/C++】C/C++中的数组是怎么实现的?

    几乎所有的语言都把数组作为一种固有的数据类型,数组也是我们最常用的数据结构之一.在语言底层,数组是如何实现的呢?本文以抽象数据类型的形式,定义.实现数组. 创建数组,理论上,我们可以使用创建任意维度的 ...

  9. HTML5-MathML-基础篇

    MathML是数学标记语言,是一种基于XML(标准通用标记语言的子集)的标准.用来在互联网上书写数学符号和公式的置标语言. 注意:大部分浏览器都支持MathML标签,如果你的浏览器不支持该标签,可以使 ...

  10. 基于opencv图片切割

    基于opencv图片切割为n个3*3区块 工作原因,切割图片,任务急,暂留调通的源码,留以后用. package com.rosetta.image.test; import org.opencv.c ...