//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
题目地址 :
http://acm.hdu.edu.cn/showproblem.php?pid=2672
好吧..............我承认, 当我看这题的解题报告时, 我被征服了................
代码如下:
题目地址 :
http://acm.hdu.edu.cn/showproblem.php?pid=2672
好吧..............我承认, 当我看这题的解题报告时, 我被征服了................
代码如下:
//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int a[1001] = { 0, 1, 1 };
int main ()
{
// 第N个字母对应 第N个FIBONACI数列的第N项 ,当然,这是字母,要取模
for ( int i = 2; i < 1001; ++ i )
{
a[i] = ( a[i - 1] + a[i - 2] ) % 26;
}
string str;
while ( getline ( cin , str ) )
{
int num = 0;
for ( int i = 0; str[i]; ++i )
{
//对每个A-Z字符进行处理
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;
}
![](//www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)