题目描述

我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?

n=0,0种;

n=1,1种;

n=2,2种;

n=3,3种;

n=4,5种;

n=5,8种;

又是斐波那契数列 。

public class Solution {
    public int RectCover(int target) {
        int first=1;
        int second=2;
        int result=0;
        if(target<3){
           return target;
        }
        for(int i=3;i<=target;i++){
            result=first+second;
            first=second;
            second=result;
        }
        return result;
    }
}

 

10-05 20:31