Re-translate the Japanese version (#1871)

* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
This commit is contained in:
Yudong Jin
2026-03-30 07:30:15 +08:00
committed by GitHub
parent fe6443235b
commit d7b2277d2b
1444 changed files with 83312 additions and 8363 deletions
@@ -11,26 +11,26 @@ import java.util.*;
public class climbing_stairs_backtrack {
/* バックトラッキング */
public static void backtrack(List<Integer> choices, int state, int n, List<Integer> res) {
// n段目に到達したとき、解の数に1を加える
// 第 n 段に到達したら、方法数を 1 増やす
if (state == n)
res.set(0, res.get(0) + 1);
// すべての選択肢を走査
for (Integer choice : choices) {
// 剪定:n段を超えて登ることを許可しない
// 枝刈り: 第 n 段を超えないようにする
if (state + choice > n)
continue;
// 試行選択を行い、状態を更新
// 試行: 選択を行い、状態を更新
backtrack(choices, state + choice, n, res);
// 撤回
// バックトラック
}
}
/* 階段登り:バックトラッキング */
public static int climbingStairsBacktrack(int n) {
List<Integer> choices = Arrays.asList(1, 2); // 1段または2段登ることを選択可能
int state = 0; // 0段目からり始める
List<Integer> choices = Arrays.asList(1, 2); // 1 段または 2 段上ることを選べる
int state = 0; // 第 0 段からり始める
List<Integer> res = new ArrayList<>();
res.add(0); // res[0] を使用して解の数を記録
res.add(0); // res[0] を使って方法数を記録する
backtrack(choices, state, n, res);
return res.get(0);
}
@@ -39,6 +39,6 @@ public class climbing_stairs_backtrack {
int n = 9;
int res = climbingStairsBacktrack(n);
System.out.println(String.format("%d段の階段を登る解は%d通りです", n, res));
System.out.println(String.format("%d 段の階段の登り方は全部で %d 通り", n, res));
}
}
}