Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wushizhenking
CS-Notes
提交
91a707ec
C
CS-Notes
项目概览
wushizhenking
/
CS-Notes
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
CS-Notes
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91a707ec
编写于
5月 03, 2019
作者:
C
CyC2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
auto commit
上级
a15c26d4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
30 addition
and
2 deletion
+30
-2
docs/notes/剑指 Offer 题解 - 10~19.md
docs/notes/剑指 Offer 题解 - 10~19.md
+15
-1
docs/pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg
docs/pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg
+0
-0
docs/pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png
docs/pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png
+0
-0
docs/pics/fec3ba89-115a-4cf9-b165-756757644641.png
docs/pics/fec3ba89-115a-4cf9-b165-756757644641.png
+0
-0
notes/pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg
notes/pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg
+0
-0
notes/pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png
notes/pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png
+0
-0
notes/pics/fec3ba89-115a-4cf9-b165-756757644641.png
notes/pics/fec3ba89-115a-4cf9-b165-756757644641.png
+0
-0
notes/剑指 Offer 题解 - 10~19.md
notes/剑指 Offer 题解 - 10~19.md
+15
-1
未找到文件。
docs/notes/剑指 Offer 题解 - 10~19.md
浏览文件 @
91a707ec
...
...
@@ -65,7 +65,7 @@ public int Fibonacci(int n) {
}
```
由于待求解的 n 小于 40,因此可以将前 40 项的结果先进行计算,之后就能以 O(1) 时间复杂度得到第 n 项的值
了
。
由于待求解的 n 小于 40,因此可以将前 40 项的结果先进行计算,之后就能以 O(1) 时间复杂度得到第 n 项的值。
```
java
public
class
Solution
{
...
...
@@ -96,6 +96,20 @@ public class Solution {
## 解题思路
当 n 为 1 时,只有一种覆盖方法:
<div align="center">
<img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/fec3ba89-115a-4cf9-b165-756757644641.png" width="100px">
</div><br>
当 n 为 2 时,有两种覆盖方法:
<div align="center">
<img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/db85a909-5e11-48b2-85d2-f003e7bb35c0.png" width="200px">
</div><br>
要覆盖 2
\*
n 的大矩形,可以先覆盖 2
\*
1 的矩形,再覆盖 2
\*
(n-1) 的矩形;或者先覆盖 2
\*
2 的矩形,再覆盖 2
\*
(n-2) 的矩形。而覆盖 2
\*
(n-1) 和 2
\*
(n-2) 的矩形可以看成子问题。该问题的递推公式如下:
<!-- <div align="center"><img src="https://latex.codecogs.com/gif.latex?f(n)=\left\{\begin{array}{rcl}1&&{n=1}\\2&&{n=2}\\f(n-1)+f(n-2)&&{n>
1}
\e
nd{array}
\r
ight." class="mathjax-pic"/>
</div>
<br>
-->
<div align="center">
<img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg" width="350px">
</div><br>
```
java
public
int
RectCover
(
int
n
)
{
if
(
n
<=
2
)
...
...
docs/pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg
0 → 100644
浏览文件 @
91a707ec
9.9 KB
docs/pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png
0 → 100644
浏览文件 @
91a707ec
2.6 KB
docs/pics/fec3ba89-115a-4cf9-b165-756757644641.png
0 → 100644
浏览文件 @
91a707ec
1.2 KB
notes/pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg
0 → 100644
浏览文件 @
91a707ec
9.9 KB
notes/pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png
0 → 100644
浏览文件 @
91a707ec
2.6 KB
notes/pics/fec3ba89-115a-4cf9-b165-756757644641.png
0 → 100644
浏览文件 @
91a707ec
1.2 KB
notes/剑指 Offer 题解 - 10~19.md
浏览文件 @
91a707ec
...
...
@@ -65,7 +65,7 @@ public int Fibonacci(int n) {
}
```
由于待求解的 n 小于 40,因此可以将前 40 项的结果先进行计算,之后就能以 O(1) 时间复杂度得到第 n 项的值
了
。
由于待求解的 n 小于 40,因此可以将前 40 项的结果先进行计算,之后就能以 O(1) 时间复杂度得到第 n 项的值。
```
java
public
class
Solution
{
...
...
@@ -96,6 +96,20 @@ public class Solution {
## 解题思路
当 n 为 1 时,只有一种覆盖方法:
<div align="center">
<img src="pics/fec3ba89-115a-4cf9-b165-756757644641.png" width="100px">
</div><br>
当 n 为 2 时,有两种覆盖方法:
<div align="center">
<img src="pics/db85a909-5e11-48b2-85d2-f003e7bb35c0.png" width="200px">
</div><br>
要覆盖 2
\*
n 的大矩形,可以先覆盖 2
\*
1 的矩形,再覆盖 2
\*
(n-1) 的矩形;或者先覆盖 2
\*
2 的矩形,再覆盖 2
\*
(n-2) 的矩形。而覆盖 2
\*
(n-1) 和 2
\*
(n-2) 的矩形可以看成子问题。该问题的递推公式如下:
<!-- <div align="center"><img src="https://latex.codecogs.com/gif.latex?f(n)=\left\{\begin{array}{rcl}1&&{n=1}\\2&&{n=2}\\f(n-1)+f(n-2)&&{n>
1}
\e
nd{array}
\r
ight." class="mathjax-pic"/>
</div>
<br>
-->
<div align="center">
<img src="pics/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg" width="350px">
</div><br>
```
java
public
int
RectCover
(
int
n
)
{
if
(
n
<=
2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录