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
@@ -7,31 +7,31 @@ Author: krahets (krahets@163.com)
def backtrack(choices: list[int], state: int, n: int, res: list[int]) -> int:
"""バックトラッキング"""
# n 段目に登ったとき、解の数に 1 を加える
# n 段に到達したら、方法数を 1 増やす
if state == n:
res[0] += 1
# すべての選択肢を走査
for choice in choices:
# 枝刈りn 段を超えて登ることを許可しない
# 枝刈り: 第 n 段を超えないようにする
if state + choice > n:
continue
# 試行選択を行い、状態を更新
# 試行: 選択を行い、状態を更新
backtrack(choices, state + choice, n, res)
# 撤回
# バックトラック
def climbing_stairs_backtrack(n: int) -> int:
"""階段登り:バックトラッキング"""
choices = [1, 2] # 1 段または 2 段ることを選択可能
state = 0 # 0 段からり始める
res = [0] # res[0] を使用して解の数を記録
choices = [1, 2] # 1 段または 2 段ることを選べる
state = 0 # 0 段からり始める
res = [0] # res[0] を使って方法数を記録する
backtrack(choices, state, n, res)
return res[0]
"""ドライバーコード"""
"""Driver Code"""
if __name__ == "__main__":
n = 9
res = climbing_stairs_backtrack(n)
print(f"{n}登り、合計 {res} 通りの解がある")
print(f"{n}の階段を上る方法は全部で {res} 通りです")