Problem F: 铺地砖

Description

元旦过去了,新年大酬宾活动也已经告一段落了。陈盖历望着堆在仓库的瓷砖,很无聊的他把这些瓷砖裁成很多1X1 1X2 1X3的小瓷砖,然后他把这些小瓷砖排在地上画的一个1*n的长方形里。问铺满这个长方形共有多少种方法?

Input

首先输入一个整数T,表示有T组测试数据 然后是T行,每行输入1个正整数n(n<=50)

Output

对于每个n输出铺的方法种数

Sample Input

3
1
2
3

Sample Output

1
2
4
#include<stdio.h>
int main(void)
{
    int T,n;
    long long f[60];
    f[1]=1;
    f[2]=2;
    f[3]=4;
    for(int i=4;i<51;i++)
    f[i]=f[i-1]+f[i-2]+f[i-3];
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        printf("%d\n",f[n]);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/chenlong991223/p/10259566.html