diff --git a/notes/10.2 矩形覆盖.md b/notes/10.2 矩形覆盖.md index 89b56563..7d745736 100644 --- a/notes/10.2 矩形覆盖.md +++ b/notes/10.2 矩形覆盖.md @@ -2,7 +2,7 @@ ## 题目描述 -我们可以用 2\*1 的小矩形横着或者竖着去覆盖更大的矩形。请问用 n 个 2\*1 的小矩形无重叠地覆盖一个 2\*n 的大矩形,总共有多少种方法? +可以用 2\*1 的小矩形横着或者竖着去覆盖更大的矩形。请问用 n 个 2\*1 的小矩形无重叠地覆盖一个 2\*n 的大矩形,总共有多少种方法?

@@ -10,17 +10,15 @@ 当 n 为 1 时,只有一种覆盖方法: -

+

当 n 为 2 时,有两种覆盖方法: -

+

要覆盖 2\*n 的大矩形,可以先覆盖 2\*1 的矩形,再覆盖 2\*(n-1) 的矩形;或者先覆盖 2\*2 的矩形,再覆盖 2\*(n-2) 的矩形。而覆盖 2\*(n-1) 和 2\*(n-2) 的矩形可以看成子问题。该问题的递推公式如下: - - -

+

```java public int rectCover(int n) { diff --git a/notes/pics/rect-cover-formula.png b/notes/pics/rect-cover-formula.png new file mode 100644 index 00000000..1338e2d5 Binary files /dev/null and b/notes/pics/rect-cover-formula.png differ diff --git a/notes/pics/rect-cover-n1.png b/notes/pics/rect-cover-n1.png new file mode 100644 index 00000000..021a5887 Binary files /dev/null and b/notes/pics/rect-cover-n1.png differ diff --git a/notes/pics/rect-cover-n2.png b/notes/pics/rect-cover-n2.png new file mode 100644 index 00000000..03612f54 Binary files /dev/null and b/notes/pics/rect-cover-n2.png differ