首页 > ACM题库 > HDU-杭电 > hdu 2672 god is a girl[解题报告]C++
2014
02-12

hdu 2672 god is a girl[解题报告]C++

god is a girl

问题描述 :

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.

输入:

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

输出:

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

样例输入:

SGC CGGJX GC BMHVQ BGU BCIHNYNBX GNPLV!

样例输出:

THE FLOWS OF MAGIC ARE WHIMSICAL TODAY!

/*
分析:
    和那位前辈一样,看到结题报告的那一刻,我
被征服了。。。囧~

                                    2012-09-16
*/

#include"stdio.h"
#include"string.h"
#include"ctype.h"
int main()
{
	int a[1001]={0,1,1};
	char str[1011];
	int i;
	int num;

	for(i=3;i<=1000;i++)	a[i]=(a[i-1]+a[i-2])%26;

	while(gets(str))
	{
		num=0;
		for(i=0;str[i];i++)
		{
			if(isupper(str[i]))
			{
				num++;
				printf("%c",isupper(str[i]+a[num])?str[i]+a[num]:str[i]+a[num]-26);
			}
			else	printf("%c",str[i]);
		}
		printf("\n");
	}
	return 0;
}

解题转自:http://blog.csdn.net/ice_crazy/article/details/7985215


  1. 网站做得很好看,内容也多,全。前段时间在博客园里看到有人说:网页的好坏看字体。觉得微软雅黑的字体很好看,然后现在这个网站也用的这个字体!nice!