1048


The Hardest Problem Ever

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

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


#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <cstdio>
using namespace std;
map<char,char> mp;
void init(){
mp[‘A‘]=‘V‘;mp[‘B‘]=‘W‘;mp[‘C‘]=‘X‘;mp[‘D‘]=‘Y‘;mp[‘E‘]=‘Z‘;mp[‘F‘]=‘A‘;mp[‘G‘]=‘B‘;mp[‘H‘]=‘C‘;mp[‘I‘]=‘D‘;mp[‘J‘]=‘E‘;
mp[‘K‘]=‘F‘;mp[‘L‘]=‘G‘;mp[‘M‘]=‘H‘;mp[‘N‘]=‘I‘;mp[‘O‘]=‘J‘;mp[‘P‘]=‘K‘;mp[‘Q‘]=‘L‘;mp[‘R‘]=‘M‘;mp[‘S‘]=‘N‘;mp[‘T‘]=‘O‘;
mp[‘U‘]=‘P‘;mp[‘V‘]=‘Q‘;mp[‘W‘]=‘R‘;mp[‘X‘]=‘S‘;mp[‘Y‘]=‘T‘;mp[‘Z‘]=‘U‘;//打表是个好方法
}
int main(){
//freopen("1.txt","r",stdin);
init();
char ss[1005];
string s1,s2,s3;
while(gets(ss)){
if(strcmp("START",ss)==0);//如果符合这个条件的话什么都不做
else if(strcmp("END",ss)==0)puts("");//输出回车
else if(strcmp("ENDOFINPUT",ss)==0)return 0;
else{
int len=strlen(ss);
for(int i=0;i<len;++i){
if(ss[i]>=‘A‘&&ss[i]<=‘Z‘)
printf("%c",mp[ss[i]]);
else
printf("%c",ss[i]);
}
}
}
return 0;
}

1048

时间: 2024-10-18 09:12:55

1048的相关文章

1048: 导弹防御系统

1048: 导弹防御系统 时间限制: 1 Sec  内存限制: 128 MB提交: 836  解决: 349[提交][状态][讨论版] 题目描述 某国为了防御敌国的导弹袭击,开发出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度.某天,雷达捕捉到敌国的导弹来袭,并观测到导弹依次飞来的高度,请计算这套系统最多能拦截多少导弹.拦截来袭导弹时,必须按来袭导弹袭击的时间顺序,不允许先拦截后面的导弹,再拦截前面的导弹. 输入

UVA 1048 - Low Cost Air Travel(最短路)

UVA 1048 - Low Cost Air Travel 题目链接 题意:给定一些联票,在给定一些行程,要求这些行程的最小代价 思路:最短路,一张联票对应几个城市就拆成多少条边,结点表示的是当前完成形成i,在城市j的状态,这样去进行最短路,注意这题有坑点,就是城市编号可能很大,所以进行各种hash 代码: #include <cstdio> #include <cstring> #include <vector> #include <queue> #in

The Hardest Problem Ever(杭电1048)

/*The Hardest Problem Ever 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 c

HDU 1048 What Is Your Grade? (简单模拟)

 What Is Your Grade? Problem Description "Point, point, life of student!" This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in

1048 石子归并

1048 石子归并 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 有n堆石子排成一列,每堆石子有一个重量w[i], 每次合并可以合并相邻的两堆石子,一次合并的代价为两堆石子的重量和w[i]+w[i+1].问安排怎样的合并顺序,能够使得总合并代价达到最小. 输入描述 Input Description 第一行一个整数n(n<=100) 第二行n个整数w1,w2...wn  (wi <= 100) 输出描述 Output Des

九度oj 题目1048:判断三角形类型

题目1048:判断三角形类型 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:8240 解决:3992 题目描述: 给定三角形的三条边,a,b,c.判断该三角形类型. 输入: 测试数据有多组,每组输入三角形的三条边. 输出: 对于每组输入,输出直角三角形.锐角三角形.或是钝角三角形. 样例输入: 3 4 5 样例输出: 直角三角形 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 i

1048: [HAOI2007]分割矩阵——记忆化搜索

http://www.lydsy.com/JudgeOnline/problem.php?id=1048 TML了一发 #include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #define clr(a,b) memset(a,b,sizeof(a)) const double INF = 0x3f3f3f3f;

JAVA HDU 1048 The Hardest Problem Ever

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1048 1 package hdu; 2 3 import java.io.BufferedInputStream; 4 import java.util.Scanner; 5 6 public class hdu_1048 { 7 8 public static void main(String[] args) { 9 Scanner in = new Scanner(new BufferedInp

hihoCoder 1048 : 状态压缩&#183;二

题目链接:http://hihocoder.com/problemset/problem/1048 题目大意:用1*2或者2*1的方块铺满一个N*M的大方格,共有多少种方法.结果对1e9+7取余.2<=N<=1000, 3<=m<=5 解题思路:挑战程序设计竞赛上有基本上一样的题目,可以参考,原题中也有提示.大致思路就是,如果从左往右铺的话,那么对第i行j列的方块来说,第i-1行的方块一定全部铺过,第j+2行的一定没有铺过.所以我们可以保存第i行和第i+1行的状态,然后递推.又由于

CODEVS 1048 石子归并 题解

此文为博主原创题解,转载时请通知博主,并把原文链接放在正文醒目位置. 题目链接:http://codevs.cn/problem/1048/ 题目描述 Description 有n堆石子排成一列,每堆石子有一个重量w[i], 每次合并可以合并相邻的两堆石子,一次合并的代价为两堆石子的重量和w[i]+w[i+1].问安排怎样的合并顺序,能够使得总合并代价达到最小. 输入描述 Input Description 第一行一个整数n(n<=100) 第二行n个整数w1,w2...wn  (wi <=