Problem Description
有一个大小是 2 x n 的网格,现在需要用2种规格的骨牌铺满,骨牌规格分别是 2 x 1 和 2 x 2,请计算一共有多少种铺设的方法。
 
Input
输入的第一行包含一个正整数T(T<=20),表示一共有 T组数据,接着是T行数据,每行包含一个正整数N(N<=30),表示网格的大小是2行N列。
 
Output
输出一共有多少种铺设的方法,每组数据的输出占一行。
 
Sample Input
3
2
8
12
 
Sample Output
3
171
2731
 
 
Code
View Code
Key Points
what you should care about is just the formula f(n)=f(n-1)+2*f(n-2).
for f(n), if you put the 2*1 card standing by its end, this is f(n-1), if you put the 2*1 cards by accross, this is f(n-2), besides you put the 2*2 card. Consequently, add together, you will the regular. 
posted on 2012-11-09 20:46  MrMission  阅读(185)  评论(0编辑  收藏  举报