标签:
用2个组合为3种情况,4,6,8......为2种情况
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std ;
const int maxn = 40 ;
typedef long long ll ;
ll a[maxn] ;
ll dp[maxn] ;
int main()
{
// freopen("in.txt","r",stdin) ;
// freopen("out.txt","w",stdout);
for(int i = 1;i <= maxn/2 ;i++)
a[i] = i == 1 ? 3 : 2 ;
int n ;
while(~scanf("%d" ,&n) && n!=-1)
{
if(n&1)puts("0") ;
else
{
dp[1] = 3;dp[0] = 1;
for(int i = 2;i <= n/2 ;i++)
{
dp[i] = a[i] ;
for(int j = 1;j < i;j++)
dp[i] += a[i-j]*dp[j];
}
printf("%lld\n",dp[n/2]) ;
}
}
return 0;
}
标签:
原文地址:http://blog.csdn.net/cq_pf/article/details/45676589