牛客网-《剑指offer》-矩形覆盖

题目:http://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6

C++

 1 class Solution {
 2 public:
 3     int rectCover(int n) {
 4         if (n == 1 || n == 2) return n;
 5         int a = 1, b = 1;
 6         while (n-- >= 2) {
 7             a = a + b;
 8             b = a - b;
 9         }
10         return a;
11     }
12 };

 

你可能感兴趣的:(牛客网-《剑指offer》-矩形覆盖)