矩形覆盖 牛客网 剑指Offer
题目描述我们可以用21的小矩形横着或者竖着去覆盖更大的矩形。请问用n个21的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?
class Solution:
def rectCover(self, number):
if number <= 0:
return 0
if number == 1:
return 1
if number == 2:
return 2
i = 3
f_1 = 1
f_2 = 2
ret = None
while i<=number:
ret = f_1 + f_2
f_1 = f_2
f_2 = ret
i += 1
return ret
转载于:https://www.cnblogs.com/vercont/p/10210359.html