hdoj2045

#include <iostream>
using namespace std;
int main() {
    long long n,f[60];
    f[1]=3;f[2]=6;f[3]=6;
    for(int i=4;i<=60;i++)
        f[i]=2*f[i-2]+f[i-1];
    while(cin>>n)
    {
        cout<<f[n]<<endl;
    }
    return 0;
}

静心思考。。。

考虑为5个空格

R P G P  G

R P R G  P 

           P  G

这两种可能(及4个空格下满足的情况)后面都只能再跟一种可能,正好等于f[4]

R P G R  (P/G) 

这种情况在4个空格是是不被考虑的,其可能性这好等于f[3],但在5个空格是可行的。

posted @ 2012-11-08 20:13  茉莉花茶  阅读(258)  评论(0编辑  收藏  举报