题解 | #矩形覆盖#
数值的整数次方
http://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00
看了别人的题解,可以发现规律,这边尝试用递归来做。
代码(可能不够优美)
class Solution { public: int rectCover(int number) { if(number == 1) return 1; if(number == 2) return 2; if(number >= 3) return rectCover(number-1) + rectCover(number-2); return 0; } };