I Love You Too
2014-08-03 11:57
190 查看
Problem Description
This is a true story. A man showed his love to a girl,but the girl didn't replied clearly ,but 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.
SampleInput
SampleOutput
[/code]
This is a true story. A man showed his love to a girl,but the girl didn't replied clearly ,but 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.
SampleInput
4194418141634192622374 41944181416341926223
SampleOutput
ILOVEYOUTOO VOYEUOOTIO
//标程:
#include<iostream> #include<cstring> #include<string> #include<cstdio> #include<algorithm> using namespace std; string s[15], s1, s2; string a = "QWERTYUIOPASDFGHJKLZXCVBNM"; string b = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void init() { s[2] = "ABC"; s[3] = "DEF"; s[4] = "GHI"; s[5] = "JKL"; s[6] = "MNO"; s[7] = "PQRS"; s[8] = "TUV"; s[9] = "WXYZ"; } void fun(char ch1,char ch2) { int i = ch1 - '0', j = ch2 - '0'; s1 += s[i][j-1]; } void conversion() { for(int i = 0; i < s1.size(); ++ i) s2 += b[a.find(s1[i])]; } int main() { // freopen("a.txt","r",stdin); init(); string str; int i; while(cin >> str) { s1 = s2 = ""; for(i = 0; i < str.size(); i += 2) fun(str[i],str[i+1]); int len = (s1.size() + 1) /2; conversion(); string s_1 = s2.substr(0,len); string s_2 = s2.substr(len,s1.size()-len); string s_3 = ""; for(i = 0; i < s_2.size(); ++ i) { s_3 += s_1[i]; s_3 += s_2[i]; } if(s_1.size() > s_2.size()) s_3 += s_1[i]; reverse(s_3.begin(),s_3.end()); cout << s_3 << endl; } return 0; }
[/code]
相关文章推荐
- hd2816 I Love You Too
- I Love You Too
- I LOVE YOU TOO密码解析
- hdu——2816——I Love You Too
- hdu-2816 I Love You Too
- hdoj 2816 I Love You Too
- I LOVE YOU TOO密码解析
- HDU 2816 ( I Love You Too )
- HDU 2816 I Love You Too
- HDU 2816 ( I Love You Too )
- HDU-2816 I Love You Too【字符串】
- hdoj 2816 I Love You Too 【模拟题】
- HDU 2816 I Love You Too
- hdu杭电 2816 I Love You Too
- E - I Love You Too解题报告(陈渊)
- E - I Love You Too解题报告
- HDOJ I Love You Too (第一周)
- HDU---2816 I LOVE YOU TOO
- HDU - 2816 I Love You Too(水)
- hdu 2816 I Love You Too