HDU_2046——骨牌铺放问题,递推

Problem Description
在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图:
 
Input
输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0<n<=50)。
 
Output
对于每个测试实例,请输出铺放方案的总数,每个实例的输出占一行。
 
Sample Input
1 3 2
 
Sample Output
1 3 2
 1 #include <cstdio>
 2 int main()
 3 {
 4     int n;
 5     double ans[51]={0,1,2,3};
 6     for(int i=4;i<51;i++)
 7         {
 8             ans[i]=ans[i-1]+ans[i-2];
 9         }
10     while(~scanf("%d",&n))
11         {
12             printf("%.lf
",ans[n]);
13         }
14     return 0;
15 }
——现在的努力是为了小时候吹过的牛B!!
原文地址:https://www.cnblogs.com/pingge/p/3182832.html