From 8f3e9c268ffbd8b94d203ffc6432d90b400c4e44 Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sun, 25 Oct 2026 19:03:37 +0800 Subject: [PATCH] =?UTF-8?q?Update=2010.4=20=E5=8F=98=E6=80=81=E8=B7=B3?= =?UTF-8?q?=E5=8F=B0=E9=98=B6.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 代码块语言 source-java 改为 java,公式代码块标注语言。 --- notes/10.4 变态跳台阶.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/notes/10.4 变态跳台阶.md b/notes/10.4 变态跳台阶.md index f6099a17..63d495d7 100644 --- a/notes/10.4 变态跳台阶.md +++ b/notes/10.4 变态跳台阶.md @@ -29,31 +29,31 @@ public int jumpFloorII(int target) { 跳上 n-1 级台阶,可以从 n-2 级跳 1 级上去,也可以从 n-3 级跳 2 级上去...,那么 -``` +```text f(n-1) = f(n-2) + f(n-3) + ... + f(0) ``` 同样,跳上 n 级台阶,可以从 n-1 级跳 1 级上去,也可以从 n-2 级跳 2 级上去... ,那么 -``` +```text f(n) = f(n-1) + f(n-2) + ... + f(0) ``` 综上可得 -``` +```text f(n) - f(n-1) = f(n-1) ``` 即 -``` +```text f(n) = 2*f(n-1) ``` 所以 f(n) 是一个等比数列 -```source-java +```java public int JumpFloorII(int target) { return (int) Math.pow(2, target - 1); }