题目描述
我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?
解题思路
参考跳台阶,可以发现可以转化为斐波那契数列解题思路
/**
* 矩形覆盖
* @author admin
*
*/
public class test12 {
public static void main(String[] args) {
int count = RectCover(10);
}
public static int RectCover(int target) {
if(target <= 0) {
return 0;
}
if(target == 1 || target == 2) {
return target;
}
return RectCover(target - 1) + (target - 2);
}
}