首页 > 代码库 > HDU1143 Tri Tiling 递推

HDU1143 Tri Tiling 递推

#include<stdio.h>
int main()
{
	int f[31];
	int i,L;
	int n;


	f[0]=1;
	for(i=1;i<=30;i+=2)	f[i]=0;
	for(i=2;i<=30;i+=2)
	{
		f[i]=0;
		for(L=2;L<=i;L+=2)
		{
			if(L==2)	f[i]+=3*f[i-L];
			else		f[i]+=2*f[i-L];
		}
	}


	while(scanf("%d",&n),n!=-1)	printf("%d\n",f[n]);
	return 0;
}

HDU1143 Tri Tiling 递推