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. ...
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 }