Retranslate the complete Japanese online edition from Chinese (#2008)

* Retranslate the complete Japanese online edition from Chinese

* Fit Japanese homepage labels and localize heading permalinks

* Point Japanese contribution instructions to the Japanese preview

* Replace locale conditionals with multilingual UI tables
This commit is contained in:
Yudong Jin
2026-10-30 02:12:26 +08:00
committed by GitHub
parent 455e8c1281
commit 7257641e0e
1987 changed files with 23531 additions and 23261 deletions
@@ -9,24 +9,24 @@ package chapter_dynamic_programming;
import java.util.Arrays;
public class coin_change {
/* コイン両替:動的計画法 */
/* 硬貨の両替:動的計画法 */
static int coinChangeDP(int[] coins, int amt) {
int n = coins.length;
int MAX = amt + 1;
// dp テーブルを初期化
// dp テーブルを初期化する
int[][] dp = new int[n + 1][amt + 1];
// 状態遷移:先頭行と先頭列
for (int a = 1; a <= amt; a++) {
dp[0][a] = MAX;
}
// 状態遷移: 残りの行と列
// 状態遷移:残りの行と列
for (int i = 1; i <= n; i++) {
for (int a = 1; a <= amt; a++) {
if (coins[i - 1] > a) {
// 目標金額を超えるなら硬貨 i は選ばない
// 目標金額を超える場合、硬貨 i を選ばない
dp[i][a] = dp[i - 1][a];
} else {
// 硬貨 i を選ばない場合と選ぶ場合の小さい方
// 硬貨 i を選ばない場合と選ぶ場合の小さいほうの値
dp[i][a] = Math.min(dp[i - 1][a], dp[i][a - coins[i - 1]] + 1);
}
}
@@ -34,11 +34,11 @@ public class coin_change {
return dp[n][amt] != MAX ? dp[n][amt] : -1;
}
/* コイン交換:空間最適化後の動的計画法 */
/* 硬貨の両替:空間を最適化した動的計画法 */
static int coinChangeDPComp(int[] coins, int amt) {
int n = coins.length;
int MAX = amt + 1;
// dp テーブルを初期化
// dp テーブルを初期化する
int[] dp = new int[amt + 1];
Arrays.fill(dp, MAX);
dp[0] = 0;
@@ -46,10 +46,10 @@ public class coin_change {
for (int i = 1; i <= n; i++) {
for (int a = 1; a <= amt; a++) {
if (coins[i - 1] > a) {
// 目標金額を超えるなら硬貨 i は選ばない
// 目標金額を超える場合、硬貨 i を選ばない
dp[a] = dp[a];
} else {
// 硬貨 i を選ばない場合と選ぶ場合の小さい方
// 硬貨 i を選ばない場合と選ぶ場合の小さいほうの値
dp[a] = Math.min(dp[a], dp[a - coins[i - 1]] + 1);
}
}
@@ -63,10 +63,10 @@ public class coin_change {
// 動的計画法
int res = coinChangeDP(coins, amt);
System.out.println("目標金額に必要な最小硬貨枚数は " + res);
System.out.println("目標金額にするために必要な硬貨の最小枚数は " + res);
// 空間最適化後の動的計画法
// 空間を最適化した動的計画法
res = coinChangeDPComp(coins, amt);
System.out.println("目標金額に必要な最小硬貨枚数は " + res);
System.out.println("目標金額にするために必要な硬貨の最小枚数は " + res);
}
}