前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HDUOJ 2672---god is a girl 《斐波那契数》

HDUOJ 2672---god is a girl 《斐波那契数》

作者头像
Gxjun
发布2018-03-21 11:34:53
6150
发布2018-03-21 11:34:53
举报
文章被收录于专栏:mlml

god is a girl

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

Problem Description

One day,when I was dreaming,god went into my dream,she was pretty cute,just like /^_^\... I really wanted to talked to her,but my English was so poor and she was not a national god but a foreign one...After thirty minutes,she flew away...but story was not finished here,she had left a letter for me!!!What puzzled me so much is the letter was encoded.I had thought for many days,but still can't get it. Now I turn to you for help,with some limited prompts,can you help me to decode the whole letter? Prompts: GDJIJ,EL SSJT UT YWOSQNIVZMI. -> HELLO,MY NAME IS LINDAINVERS. CN WLP JRVMFGQ BVR,IJCFI? -> DO YOU REQUIRE AID,HUMAN? NMAB VYNNF, FI'E VC HP IXJ ZLQZI. -> ONCE AGAIN, IT'S UP TO THE ELVES. ...

Input

There is multy cases,please process to EOF. Each case is one line of string with uppercase letters and white spaces and other symbols.

Output

One line of the decoded string.

Sample Input

SGC CGGJX GC BMHVQ BGU BCIHNYNBX GNPLV!

Sample Output

THE FLOWS OF MAGIC ARE WHIMSICAL TODAY!

Author

Teddy

 做了两小时,一直在找规律,最后将几个句子反复对比才发现是fibonacci数的引用.....哎!!,没有多大的技巧,所以代码也没有啥好讲解的...

就是先暴力一下打一张漂亮的斐波列数表,当然数据范围是在0~25之间----为防止‘A’+25不至于超出范围,当然其他数据如‘B’+25超出了范围,则

要减去26直到最后的数不大于‘Z’即可。

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<ctype.h>
 4 #include<string.h>
 5 #pragma warning (disable: 4018)
 6 #define MAX 10000
 7 char  str[MAX+1];
 8 int arr[MAX+1]={0,1,1};
 9 int main()
10 {
11     int i,j;
12      for( i=3;i<=MAX;i++)
13   {
14     arr[i]=arr[i-1]+arr[i-2];
15     arr[i]%=26;
16   }
17   while(gets(str)!=NULL)
18   {
19       for( j=1,i=0;i<strlen(str);i++)
20       {
21           if(isupper(str[i]))
22           {
23               str[i]+=arr[j++];
24               while(str[i]>'Z')
25               {
26                 str[i]-=26;
27               }
28               
29           }
30           putchar(str[i]);
31       }
32       puts("");
33   }
34     return 0;
35 }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013-07-17 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • god is a girl
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档