E - I Love You Too解题报告(张宇)
2012-04-19 07:15
267 查看
E - I Love You Too
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU
2816
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
Sample Output
题意:给出一串长度不大于1000的数字,按每两个数字对应一个字母来解密(如图,即手机按键上的字母,如22代表B),解密后在根据解密对应的编码【3】来得到字母串,然后拆成两半(前部分不短于后部分),再按照【4】重新得到字母串,最后反序输出该字母串就ok啦。(貌似此密码很让人头疼呀。。。。别急,一步一步来,题目并不难)
[cpp] view
plaincopy
#include<iostream>
using namespace std;
int main()
{
char a[1010];
char b[505];
char c[252];
char d[252];
char ans[505];
char x[8][5]={"KXV","MCN","OPH","QRS","ZYI","JADL","EGW","BUFT"}; //已经按照密码定义了
while(scanf("%s",a)!=EOF)
{
int i,j,k;
for(i=0,j=0;i<strlen(a);i+=2,j++)
{
a[i]-='0'; //把字符转化为数字
a[i+1]-='0';
b[j]=x[a[i]-2][a[i+1]-1]; //求出每两个数字对应的一个字母
}
//要把字母串分成两个部分,而且前部分不短于后部分
for(i=0;i<((strlen(a)/2)+1)/2;i++)
c[i]=b[i];
for(j=i,k=0;j<strlen(a)/2;j++,k++)
d[k]=b[j];
j=0;k=0;
//再把两个字母串合并
for(i=0;i<strlen(a)/2;i++)
{
if((i+1)%2!=0)
ans[i]=c[j++];
else
ans[i]=d[k++];
}
for(i=strlen(a)/2-1;i>=0;i--)
printf("%c",ans[i]);
printf("\n");
}
return 0;
}
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU
2816
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
题意:给出一串长度不大于1000的数字,按每两个数字对应一个字母来解密(如图,即手机按键上的字母,如22代表B),解密后在根据解密对应的编码【3】来得到字母串,然后拆成两半(前部分不短于后部分),再按照【4】重新得到字母串,最后反序输出该字母串就ok啦。(貌似此密码很让人头疼呀。。。。别急,一步一步来,题目并不难)
[cpp] view
plaincopy
#include<iostream>
using namespace std;
int main()
{
char a[1010];
char b[505];
char c[252];
char d[252];
char ans[505];
char x[8][5]={"KXV","MCN","OPH","QRS","ZYI","JADL","EGW","BUFT"}; //已经按照密码定义了
while(scanf("%s",a)!=EOF)
{
int i,j,k;
for(i=0,j=0;i<strlen(a);i+=2,j++)
{
a[i]-='0'; //把字符转化为数字
a[i+1]-='0';
b[j]=x[a[i]-2][a[i+1]-1]; //求出每两个数字对应的一个字母
}
//要把字母串分成两个部分,而且前部分不短于后部分
for(i=0;i<((strlen(a)/2)+1)/2;i++)
c[i]=b[i];
for(j=i,k=0;j<strlen(a)/2;j++,k++)
d[k]=b[j];
j=0;k=0;
//再把两个字母串合并
for(i=0;i<strlen(a)/2;i++)
{
if((i+1)%2!=0)
ans[i]=c[j++];
else
ans[i]=d[k++];
}
for(i=strlen(a)/2-1;i>=0;i--)
printf("%c",ans[i]);
printf("\n");
}
return 0;
}
相关文章推荐
- E - I Love You Too解题报告(陈渊)
- E - I Love You Too解题报告
- HDU-1086 You can Solve a Geometry Problem too 解题报告
- HDU-1086 You can Solve a Geometry Problem too 解题报告
- HDU 4723 How Long Do You Have to Draw 解题报告
- HDU-2816 I Love You Too【字符串】
- 155A. I_love_%username% 解题报告
- acm解题报告 HDU 2199 Can you solve this equation?
- HDU 4724 If You Know This,You Must Have NO GF 解题报告
- hdu 2816 I Love You Too
- H - Climbing Worm解题报告(张宇)
- HDU---2816 I LOVE YOU TOO
- A - A hard puzzle解题报告(张宇)
- HDU 2816 I Love You Too
- hdu-2816-I Love You Too
- hdu-2816 I Love You Too
- HDU1075 What Are You Talking About 解题报告--字典树
- HDU 2816 I Love You Too [Ad Hoc]
- hdoj 2816 I Love You Too
- I LOVE YOU TOO密码解析