I Love You Too

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1756    Accepted Submission(s):
1056

Problem Description
This is a true story. A man showed his
love to a girl,but the girl didn't replied clearly ,just gave him a Morse
Code:
****-/*----/----*/****-/****-/*----/---**/*----/****-/*----/-****/***--/****-/*----/----*/**---/-****/**---/**---/***--/--***/****-/
  He was so anxious that he asked for help in the Internet and after one day a
girl named "Pianyi angel" found the secret of this code. She translate this code
as this five steps:
1.First translate the morse code to a number
string:4194418141634192622374
2.Second she cut two number as one group
41 94 41 81 41 63 41 92 62 23 74,according to standard Mobile phone can
get this alphabet:GZGTGOGXNCS

3.Third she change
this alphabet according to the keyboard:QWERTYUIOPASDFGHJKLZXCVBNM =
ABCDEFGHIJKLMNOPQRSTUVWXYZ

So ,we can get OTOEOIOUYVL
4.Fourth,
divide this alphabet to two parts: OTOEOI and OUYVL, compose
again.we will get OOTUOYEVOLI
5.Finally,reverse this alphabet the
answer will appear : I LOVE YOU TOO

I guess you might
worship Pianyi angel as me,so let's Orz her.
Now,the task is translate the
number strings.
 
Input
A number string each line(length <= 1000). I ensure
all input are legal.
 
Output
An upper alphabet string.
 
Sample Input
4194418141634192622374
41944181416341926223
 
Sample Output
ILOVEYOUTOO
VOYEUOOTIO
不断地模拟,根据题目翻译密码
#include<stdio.h>
#include<string.h>
#define MAX 1100
char s[MAX];
int a[30];
char str2[MAX];
char str5[MAX];
char str3[30]={"QWERTYUIOPASDFGHJKLZXCVBNM"};
char str4[30]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
char str1[20][5]={"\0","\0","ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"};
char str6[MAX],str7[MAX];
int main()
{
int n,m,j,i,t,l1,l2,l3,l4;
while(scanf("%s",s)!=EOF)
{
memset(a,0,sizeof(a));
memset(str2,'\0',sizeof(str2));
memset(str5,'\0',sizeof(str5));
memset(str6,'\0',sizeof(str6));
memset(str7,'\0',sizeof(str7));
l1=strlen(s);
j=0;
for(i=0;i<l1;i=i+2,j++)
str2[j]=str1[s[i]-'0'][s[i+1]-'1'];
l2=strlen(str2);
for(i=0;i<l2;i++)
for(j=0;j<26;j++)
{
if(str2[i]==str3[j])
{
a[i]=j;
break;
}
}
for(i=0;i<l2;i++)
str5[i]=str4[a[i]];
int k=l2/2;
j=0;
if(l2&1)
{
for(i=l2-1;i>k;i--)
str6[j++]=str5[i];
j=0;
for(i=k;i>=0;i--)
str7[j++]=str5[i];
}
else
{
for(i=l2-1;i>=k;i--)
str6[j++]=str5[i];
j=0;
for(i=k-1;i>=0;i--)
str7[j++]=str5[i];
}
if(l2&1)
for(i=0;i<=k;i++)
{
printf("%c",str7[i]);
if(i==k)
break;
printf("%c",str6[i]);
}
else
for(i=0;i<k;i++)
{
printf("%c",str6[i]);
printf("%c",str7[i]);
}
printf("\n");
}
return 0;
}

  

hdoj 2816 I Love You Too的更多相关文章

  1. 杭电hdoj题目分类

    HDOJ 题目分类 //分类不是绝对的 //"*" 表示好题,需要多次回味 //"?"表示结论是正确的,但还停留在模块阶 段,需要理解,证明. //简单题看到就 ...

  2. HDOJ 题目分类

    HDOJ 题目分类 /* * 一:简单题 */ 1000:    入门用:1001:    用高斯求和公式要防溢出1004:1012:1013:    对9取余好了1017:1021:1027:   ...

  3. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  5. HDOJ 1326. Box of Bricks 纯水题

    Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  6. HDOJ 1004 Let the Balloon Rise

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  7. hdoj 1385Minimum Transport Cost

    卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...

  8. HDOJ(2056)&HDOJ(1086)

    Rectangles    HDOJ(2056) http://acm.hdu.edu.cn/showproblem.php?pid=2056 题目描述:给2条线段,分别构成2个矩形,求2个矩形相交面 ...

  9. 继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ

    前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机&quo ...

随机推荐

  1. js获取json数据

    var json = {  contry:{ area:{ man:"12万",  women:"10万" } } };//方式一:使用eval解析  var  ...

  2. Chrome浏览器报错:Origin null is not allowed by Access-Control-Allow-Origin.

    问题:Chrome浏览器报错:Origin null is not allowed by Access-Control-Allow-Origin. 原因:.js文件中使用load()方法,而Chrom ...

  3. crontab与环境变量

    一个shell脚本,直接执行能成功,但是加在crontab后确怎么也执行不成功. 问题的原因是:crontab的环境变量与直接执行用户的环境变量不一样. export PATH=$PATH:/sbin ...

  4. PHP 返回近7天 本月 上月日期

    <?php /** * 返回近7天,本月,上月数据 * 不计当天(展示后台数据专用) */ function weekMonthLastMonth($search_date = 'week') ...

  5. CentOS 6.4 播放avi格式的视频文件

    1. 需要先进行相关的yum源的导入: rpm -Uhv http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0. ...

  6. [转]CentOS Yum 命令详解

    总所周知,Redhat和Fedora的软件安装命令是rpm,但是用rpm安 装软件最大的麻烦就是需要手动寻找安装该软件所需要的一系列依赖关系,超级麻烦不说,要是软件不用了需要卸载的话由于卸载掉了某个依 ...

  7. 一个Highcharts的例子

    关键字:Highcharts <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Typ ...

  8. Scala的Option类型

    Scala的Option类型 为了让所有东西都是对象的目标更加一致,也为了遵循函数式编程的习惯,Scala鼓励你在变量和函数返回值可能不会引用任何值的时候使用Option类型.在没有值的时候,使用No ...

  9. BZOJ 1707: [Usaco2007 Nov]tanning分配防晒霜

    Description 奶牛们计划着去海滩上享受日光浴.为了避免皮肤被阳光灼伤,所有C(1 <= C <= 2500)头奶牛必须在出门之前在身上抹防晒霜.第i头奶牛适合的最小和最 大的SP ...

  10. 基于Visual C++6.0的DLL编程实现

    整理自基于Visual C++6.0的DLL编程实现 本文通过通俗易懂的方式,全面介绍了动态链接库的概念.动态链接库的创建和动态链接库的链接,并给出个简单明了的例子,相信读者看了本文后,能够创建自己的 ...