Judge Info

  • Memory Limit: 32768KB
  • Case Time Limit: 10000MS
  • Time Limit: 10000MS
  • Judger: Normal

Description

A boy and a girl both like studying code in their extra-curricular. Of course, they like each other. Therefore, the boy shows his love to the girl one day. The girl smiles and leaves a series of Morse code. After 5 times of decoding, the boy will get the answer. The boy makes his best efforts but 5 times of decoding is almost impossible. He has no choice but to ask for help on the Internet. He posts his troublesome on baidu tieba. Everyone is eager to help him. And after 6 hours, miracle happens. The boy get his answer. Beside deeply moved, the author also hope you can show him this romantic again. We will tell you the 5 times of encryption and the decoded words. We want you to tell us the original code. We suppose the original code is:

/****-/*----/----*/****-/****-/*----/---**/*----/****-/*----/-****/***--/****-/*----/----*/**---/-****/**---/**---/***--/--***/****-/

1. Using Morse code, we can transform the original code into number. Every '/' separates a number.

We will get a number list.

41 94 41 81 41 63 41 92 62 23 74

2. B. Using these numbers, in the keyboard of cell phone, we will decorate 26 letters on the key 2-9 so that we can use two numbers to get one letter. Such as 63 means the number 6 key, the 3th letter. It’s ‘O’.

The number list became a letter string

G Z G T G O G X N C S

3. Continue to our transformation, we use our computer keyboards this time. Our familiar keyboard often arranges letters in the order of "QWERTY...”. So we suppose 'Q' to 'A','W' to 'B' ..'G' to 'O'..at last 'M' to 'Z'.

The new code is

O T O E O I O U Y V L

4. We will soon get the answer after the last two steps. Are you eager to know it? This time is barrier transforming. We cut the original code into the former part and the after part. If the length of the code is odd, the former part is allowed to have one more letter than the after part. Then, put every letters of the after part into every interval of the former part. After cutting the code, we get "O T O E O I ","O U Y V L". Then after putting them alternately, we get

O O T U O Y E V O L I.

5. Clever as you, have you get the answer? If we output the strings in reverse order, we can see the simple and pure romance.

ILOVEYOUTOO (I Love You Too!)

Input

The first line is an integer t ,means the number of test cases. The next t lines, each has a string as the test data.

Output

Output the original code. (the answer won’t be longer than 30 character.)

Sample Input

/****-/*----/----*/****-/****-/*----/---**/*----/****-/*----/-****/***--/****-/*----/----*/**---/-****/**---/**---/***--/--***/****-/

Sample Output

ILOVEYOUTOO

Hint

Morse code table (number part)
0 ----- 5 *****
1 *---- 6 -****
2 **--- 7 --***
3 ***-- 8 ---**
4 ****- 9 ----* cell phone keyboard character table
2.abc 3.def
4.ghi 5.jkl
6.mno 7.pqrs
8.tuv 9.wxyz computer keyboard order table
"QWERTYUIOPASDFGHJKLZXCVBNM"

解题思路: 字符串末尾没有加'\0' 导致我4个小时调试,找大神才解决。

code :

 #include <stdio.h>
#include <string.h>
#include <stdio.h> char M[][] = {"/-----","/*----","/**---","/***--","/****-","/*****","/-****","/--***","/---**","/----*"};
char N[][]={"","","ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"};
char s[];
char A[];
int B[];
char C[];
char D[];
char T[];
char E[];
char F[];
char G[]; int main() {
int t,i,k,j, len;
scanf("%d", &t);
getchar();
strcpy(C,"QWERTYUIOPASDFGHJKLZXCVBNM"); while (t--) {
scanf("%s", s);
len = strlen(s);
for (i=;i<len;i+=) {
j=i;
k=;
while (k<)
A[k++] = s[j++];
A[] = '\0';
for(j=;j<;j++) if(strcmp(A,M[j])==) break;
B[i/] = j;
} for(i=;i<len/;++i){
T[i]=N[B[*i]][B[*i+]-];
} k=i; for(i=;i<k;i++){ for(j=;j<;++j)
if(T[i]==C[j]){
T[i]=('A'+j);
break;
}
} j=;
for(i=; i<(k-)/+; i++) {
G[j] = T[i];
j+=;
}
j=;
for(i=(k-)/+; i<k; i++) {
G[j] = T[i];
j+=;
}
G[k] = '\0'; for(i = k-; i > -; i--)
printf("%c", G[i]);
printf("\n");
}
return ;
}

dd 帮我调试的代码:

 #include <stdio.h>
#include <string.h>
#include <stdio.h> char M[][] = {"-----","*----","**---","***--","****-","*****","-****","--***","---**","----*"};
char N[][]={"",""," ABC"," DEF"," GHI"," JKL"," MNO"," PQRS"," TUV"," WXYZ"};
char s[];
char A[];
int B[];
char C[];
char D[];
char T[];
char E[];
char F[];
char G[]; int main() {
int t,i,k,j, len;
scanf("%d", &t);
getchar();
strcpy(C,"QWERTYUIOPASDFGHJKLZXCVBNM"); while (t--) {
scanf("%s", s);
len = strlen(s);
for(i = ; i < len; i++)
if(s[i] == '/')
break;
int e = ;
for (i++; i<len;i+=) {
j=i;
k=; strcpy(A, "");
strncpy(A,&s[i],);
A[]='\0'; for(j=;j<;j++) if(strcmp(A,M[j])==) break;
B[e++] = j;
} k = ;
for(i=; i<e; i+=)
T[k++] = N[B[i]][B[i+]];
T[k] = '\0'; for(i=;i<k;i++){ for(j=;j<;++j)
if(T[i]==C[j]){
T[i]=('A'+j);
break;
}
} e = ;
for(i=;i<(k-)/+;i++){
//E[i]=T[i];
G[e] = T[i];
e+=;
} e = ;
for(i=(k-)/+;i<k;i++){
//F[j++]=T[i];
G[e] = T[i];
e+=;
}
G[e] = '\0'; for(i = k-; i > -; i--)
printf("%c", G[i]);
printf("\n");
}
return ;
}

SZU:G34 Love code的更多相关文章

  1. 《Clean Code》阅读笔记

    Chapter 2  命名 命名要表现意图 避免歧义和误导,增强区分 命名可读性:便于发音,增强印象,便于交流 命名可查性:增强区分,便于搜索 类和对象的命名:名词或名词短语 方法的命名:动词或动词短 ...

  2. Visual Studio Code 代理设置

    Visual Studio Code (简称 VS Code)是由微软研发的一款免费.开源的跨平台文本(代码)编辑器,在十多年的编程经历中,我使用过非常多的的代码编辑器(包括 IDE),例如 Fron ...

  3. 我们是怎么做Code Review的

    前几天看了<Code Review 程序员的寄望与哀伤>,想到我们团队开展Code Review也有2年了,结果还算比较满意,有些经验应该可以和大家一起分享.探讨.我们为什么要推行Code ...

  4. Code Review 程序员的寄望与哀伤

    一个程序员,他写完了代码,在测试环境通过了测试,然后他把它发布到了线上生产环境,但很快就发现在生产环境上出了问题,有潜在的 bug. 事后分析,是生产环境的一些微妙差异,使得这种 bug 场景在线下测 ...

  5. 从Script到Code Blocks、Code Behind到MVC、MVP、MVVM

    刚过去的周五(3-14)例行地主持了技术会议,主题正好是<UI层的设计模式——从Script.Code Behind到MVC.MVP.MVVM>,是前一天晚上才定的,中午花了半小时准备了下 ...

  6. 在Visual Studio Code中配置GO开发环境

    一.GO语言安装 详情查看:GO语言下载.安装.配置 二.GoLang插件介绍 对于Visual Studio Code开发工具,有一款优秀的GoLang插件,它的主页为:https://github ...

  7. 代码的坏味道(14)——重复代码(Duplicate Code)

    坏味道--重复代码(Duplicate Code) 重复代码堪称为代码坏味道之首.消除重复代码总是有利无害的. 特征 两个代码片段看上去几乎一样. 问题原因 重复代码通常发生在多个程序员同时在同一程序 ...

  8. http status code

    属于转载 http status code:200:成功,服务器已成功处理了请求,通常这表示服务器提供了请求的网页 404:未找到,服务器未找到 201-206都表示服务器成功处理了请求的状态代码,说 ...

  9. Visual Studio Code——Angular2 Hello World 之 2.0

    最近看到一篇用Visual Studio Code开发Angular2的文章,也是一篇入门教程,地址为:使用Visual Studio Code開發Angular 2專案.这里按部就班的做了一遍,感觉 ...

随机推荐

  1. JavaScript通告/订阅的例子

    原文链接: Pub/Sub JavaScript Object原始日期: 2014年6一个月11日本: 2014年6月13日 翻译人员: 铁锚 高效AJAX站点的三大杀器: 事件代理, 浏览历史管理, ...

  2. 关于ACM,关于CSU

    原文地址:http://tieba.baidu.com/p/2432943599 前言: 即将进入研二,ACM的事情也渐渐远去,记忆终将模糊,但那段奋斗永远让人热血沸腾.开个贴讲讲ACM与中南的故事, ...

  3. 面向对象三大特征之继承(extends)——Java笔记(六)

    继承:            从一般到特殊的关系,是一种拓展关系,子类对象是父类的一种,也可称为”is a“的关系 泛化:         把子类里的共性抽取到父类里的来的过程 特化:         ...

  4. android 实现真正意义上的服务及源代码下载

    android APP后台服务和长期server长期互动,保证实时数据,这个小项目主要实施app退出后仍然能够执行服务. 使用该系统的Intent.ACTION_TIME_TICK现,这个系统的广播每 ...

  5. 准备战争“软测试”之DB基础知识

    "数据库"东西这个陌生和数据,进入提高班,从第二年开始接触,的项目还是自考的学习加起来也有3遍了.这仅仅是一个開始,软考又要对数据库进行全面的分析,那么如今就让我们再一次剖析它吧! ...

  6. 胖client和瘦client

    胖和瘦?纠结了妙龄少女,更郁闷了无数男女老少.每天充斥在宿舍的一句话就是:从明天開始我要减肥!!结果,可想而知,真的永远是明天而已.就这样,胖和瘦在我们人类之间无缝不在的存在着.但是client怎么就 ...

  7. UVa 740 - Baudot Data Communication Code

    称号:目前编码,他们shift键被按下,并提出,对应的两个编码,其中,2相应的编码shift操作. 给你适当的编码值.寻求相应的字符串. 分析:模拟.字符串. 简单题,标记shift的升降分类处理就可 ...

  8. WebBrowser控件应用:播放PPT文件

    原文:WebBrowser控件应用:播放PPT文件 一开始想的是用webform来做,用iframe加载文件,把ppt文件另存成htm,然后播放. 可是后来发现,的程序不大容易控制,所以改用winfo ...

  9. kprobe 内核模块

    代码来自于linux内核sample/kprobe kprobe_example.c /* * NOTE: This example is works on x86 and powerpc. * He ...

  10. hdu 4932 Miaomiao&#39;s Geometry(暴力)

    题目链接:hdu 4932 Miaomiao's Geometry 题目大意:在x坐标上又若干个点,如今要用若干条相等长度的线段覆盖这些点,若一个点被一条线段覆盖,则必须在这条线的左端点或者是右端点, ...