Update 10.3 跳台阶.md

重新绘制配图,公式中递推式的条件改为 n > 2。
This commit is contained in:
CyC2018
2026-10-28 22:51:12 +08:00
parent fe85f770bb
commit 23f83bc642
5 changed files with 4 additions and 4 deletions
+4 -4
View File
@@ -8,21 +8,21 @@
一只青蛙一次可以跳上 1 级台阶,也可以跳上 2 级。求该青蛙跳上一个 n 级的台阶总共有多少种跳法。
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/9dae7475-934f-42e5-b3b3-12724337170a.png" width="380px"> </div><br>
<div align="center"> <img src="pics/jump-floor-problem.png" width="400px"/> </div><br>
## 解题思路
当 n = 1 时,只有一种跳法:
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/72aac98a-d5df-4bfa-a71a-4bb16a87474c.png" width="250px"> </div><br>
<div align="center"> <img src="pics/jump-floor-n1.png" width="220px"/> </div><br>
当 n = 2 时,有两种跳法:
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1b80288d-1b35-4cd3-aa17-7e27ab9a2389.png" width="300px"> </div><br>
<div align="center"> <img src="pics/jump-floor-n2.png" width="450px"/> </div><br>
跳 n 阶台阶,可以先跳 1 阶台阶,再跳 n-1 阶台阶;或者先跳 2 阶台阶,再跳 n-2 阶台阶。而 n-1 和 n-2 阶台阶的跳法可以看成子问题,该问题的递推公式为:
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg" width="350px"> </div><br>
<div align="center"> <img src="pics/jump-floor-formula.png" width="400px"/> </div><br>
```java
public int trainWays(int num) {
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB