Poj1298_The Hardest Problem Ever(水题)
一、Description
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
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
二、问题分析
最近两天,哥们被三伏天折磨的想死的心都有了。于是乎,我决定找几道水题来降降温。这道号称是“史上最难的问题”的题目就是一道标准的水题。
题目很简单,密码转译问题。开始的时候以为是加密,这也算是我所唯一检查了的地方。用字符串存放输入,然后把字符串转换为字符数组。把字母分为两部分,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(水题)的更多相关文章
- fzuoj Problem 2182 水题
http://acm.fzu.edu.cn/problem.php?pid=2182 Problem 2182 水题 Accept: 188 Submit: 277Time Limit: 100 ...
- 烟大 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 ...
- [POJ 1000] A+B Problem 经典水题 C++解题报告 JAVA解题报告
A+B Problem Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 311263 Accepted: 1713 ...
- HDU 4716 A Computer Graphics Problem (水题)
A Computer Graphics Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- poj1298 The Hardest Problem Ever 简单题
链接:http://poj.org/problem?id=1298&lang=default&change=true 简单的入门题目也有这么强悍的技巧啊!! 书上面的代码: 很厉害有没 ...
- POJ1298_The Hardest Problem Ever_最难的问题_Caesar 密码_C++
题目:http://poj.org/problem?id=1298 好吧,给了题目也看不懂……给出翻译(题目名翻译是:最难的问题,233333) 这一看就是老师给出题解: 然而没有什么用哈 最快的办法 ...
- 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 ...
- 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 ...
- HDU 5443 The Water Problem (水题,暴力)
题意:给定 n 个数,然后有 q 个询问,问你每个区间的最大值. 析:数据很小,直接暴力即可,不会超时,也可以用RMQ算法. 代码如下: #include <cstdio> #includ ...
随机推荐
- Idea 使用的技巧和设置
1.自动提示时候,忽绿大小写, setting---->sensitive 2:IntelliJ IDEA报错class is never used 图中的unused declaration选 ...
- JS分段传输数据
<SCRIPT language=javascript> file://数据拆分,并放到相应的hidden域中,在Form的onSubmit事件中激发 function fnPreHand ...
- Qt插件开发入门(两种方法:High-Level API接口,Low-Level API接口)
Qt中为我们提供了两种开发插件的方式.一种是使用High-Level API接口,一种是使用Low-Level API接口.所谓High-Level API 是指通过继承Qt为我们提供的特定的插件基类 ...
- The given 'driver' ] is unknown, Doctrine currently supports only the follo wing drivers: pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci, oci8, ibm_db2, pdo
[Doctrine\DBAL\DBALException] The given 'driver' ] ...
- python元组和列表区别
元组可以简单认为是一个只读的列表 tuper = const list
- (转载)C #开源框架
Json.NET http://json.codeplex.com/ Json.Net 是一个读写Json效率比较高的.Net框架.Json.Net 使得在.Net环境下使用Json更加简单.通过Li ...
- Integer 与 int 中的 ==
public class IntegerTest { public static void main(String args[]){ /** * int == 比较大小 */ int p1 = 100 ...
- 一对多 添加表单 cocoon
gem 'cocoon' - javascript "cocoon.js" https://note.youdao.com/web/#/file/XCiivnE/note/WEB4 ...
- java搭建 SpringMVC+Mybatis(SMM)+mybatis-generate
搭建SSM系统,首先要了解整个过程: 1.创建spring-mvc项目 2.在maven中添加要引用的jar包(使用框架都是较新的版本:) 3. jdbc.xml +spring-mybatis.xm ...
- UI组件之Button
UIButton:按钮,可以实现用户和app的交互,父类是UIControl,事件驱动型的组件的父类都是UIControl.一般使用类方法创建一个对象,创建时指定button的类型, iOS7.0后采 ...