[Prove safety the offer] rectangular footprint

Title Description

We can use a small rectangle 2 * 1 sideways or vertically to cover a larger rectangle. Will the small rectangle of n 2 * 1 coverage without overlap a large rectangle 2 * n, a total of how many ways?
 
 
 
Topic links:
 
 
 
package com.sunshine.OFFER66_SECOND;

import org.junit.Test;

public class A10_RectCover {

    @Test
    public void test(){
        System.out.println(RectCover(4));
    }

    
    public int RectCover(int target) {
        if(target <= 0){
            return 0;
        }
        if(target == 2){
            return 2;
        }
        if(target == 1){
            return 1;
        }
        return RectCover(target-1)+RectCover(target-2);
    }
}

 

Guess you like

Origin www.cnblogs.com/MoonBeautiful/p/11420499.html