HDOJ I Love You Too (第一周)
来源:互联网 发布:红旗linux界面图 编辑:程序博客网 时间:2024/04/30 14:01
I Love You Too
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 11 Accepted Submission(s) : 5
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.
****-/*----/----*/****-/****-/*----/---**/*----/****-/*----/-****/***--/****-/*----/----*/**---/-****/**---/**---/***--/--***/****-/ 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
419441814163419262237441944181416341926223
Sample Output
ILOVEYOUTOOVOYEUOOTIO
读懂了就好做了,一次A
ac代码:
#include<stdio.h>#include<stdlib.h>#include<iostream>#include<algorithm>#include<string.h>using namespace std;char s1[1050][6]={{"ABC"},{"DEF"},{"GHI"},{"JKL"},{"MNO"},{"PQRS"},{"TUV"},{"WXYZ"}};//step1char s2[4][1050]={{"QWERTYUIOPASDFGHJKLZXCVBNM"},{"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}};//step2int main(){ char num[1050],s[1050]; char last[1050]; int i,j; while(scanf("%s",s)!=EOF) { int len=strlen(s); int c=0;//step1 for(i=0;i<len;) { num[c++]=s1[s[i]-'0'-2][s[i+1]-'0'-1]; i+=2; } for(j=0;j<c;j++) { for(i=0;i<26;i++) { if(s2[0][i]==num[j]) { num[j]=s2[1][i]; break; } } } int k; if(c%2==1) k=c/2+1; else k=c/2; int l=0; for(i=0,j=k;i<k;i++,j++) { last[l++]=num[i]; if(j<c) last[l++]=num[j]; } i=l-1; while(i>=0) { printf("%c",last[i]); i--; } printf("\n"); } return 0;}
0 0
- HDOJ I Love You Too (第一周)
- I Love You Too
- I Love You Too
- hdoj 2816 I Love You Too 【模拟题】
- hd2816 I Love You Too
- E - I Love You Too解题报告(陈渊)
- E - I Love You Too解题报告(张宇)
- HDU - 2816 I Love You Too(水)
- I Love You Too 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
- hdu-2816 I Love You Too
- HDU 2816 ( I Love You Too )
- E - I Love You Too解题报告
- ThinkPHP模版引擎之变量输出详解
- 安卓从imageview中获得bitmap的方法
- hdoj 1013Digital Roots
- Effective Java笔记-第9章:异常
- 史上最全的程序员求职渠道总结
- HDOJ I Love You Too (第一周)
- ubuntu彻底删除软件及配置文件
- iOS实用技巧 - AFNetworking2安全的使用自签证书访问HTTPS
- 安装完hive,启动错误解决办法
- cat 显示行号http://blog.sina.com.cn/s/blog_716844910100tfxv.html
- 欢迎使用CSDN-markdown编辑器
- 关于字体大小设置用dp还是sp
- 假期第一周周报
- 为什么不能用memcached存储Session?