https://www.nowcoder.net/practice/72a5a919508a4251859fb2cfb987a0e6?tpId=13&tqId=11163&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking
题目描述
我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?
代码如下:
class Solution { public: int rectCover(int number) { if (number < 2) return number; int ret2 = 1; int ret1 = 1; for (int i=2; i<=number; i++) { int tmp = ret2 + ret1; ret2 = ret1; ret1 = tmp; } return ret1; } };