HDU2672--god is a girl

god is a girl

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


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!
---------------------------------------------------------------------------
这题是按照斐波那契来编码的,也就是有一个斐波那契额数列{1,1,2,3,5,8,13……},然后分别对应地加上字符中的大写字母,若大于26,
就对26取余,最后再输出。
 
#include<stdio.h>
#include<string.h>
char b[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int main()
{
    __int64 a[100005],j,i,len,x;
    char str[100005];
    a[0]=1;
    a[1]=1;
    for(i=2;i<=100005;i++)
    {
        a[i]=a[i-1]+a[i-2];
        a[i]%=26;
    }
    while(gets(str))
    {
        x=0;
        len=strlen(str);
        for(i=0;i<len;i++)
        {
            for(j=0;j<26;j++)
            {
                if(str[i]==b[j])
                {
                    str[i]=b[(j+a[x++])%26];
                    break;
                }
            }
        }
        puts(str);
    }
    return 0;
}
posted on 2013-05-26 11:09  _taoGe  阅读(212)  评论(0编辑  收藏  举报