diff --git "a/JHLEE325/202511/23 BOJ G5 \355\231\200\354\210\230 \355\231\200\353\246\255 \355\230\270\354\204\235.md" "b/JHLEE325/202511/23 BOJ G5 \355\231\200\354\210\230 \355\231\200\353\246\255 \355\230\270\354\204\235.md" new file mode 100644 index 00000000..084c1725 --- /dev/null +++ "b/JHLEE325/202511/23 BOJ G5 \355\231\200\354\210\230 \355\231\200\353\246\255 \355\230\270\354\204\235.md" @@ -0,0 +1,60 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + static int min = Integer.MAX_VALUE; + static int max = Integer.MIN_VALUE; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String N = br.readLine(); + dfs(N, 0); + + System.out.println(min + " " + max); + } + + static void dfs(String num, int totalOdd) { + + int curOdd = countOdd(num); + totalOdd += curOdd; + + int len = num.length(); + + if (len == 1) { + min = Math.min(min, totalOdd); + max = Math.max(max, totalOdd); + return; + } + + if (len == 2) { + int sum = (num.charAt(0) - '0') + (num.charAt(1) - '0'); + dfs(String.valueOf(sum), totalOdd); + return; + } + + for (int i = 1; i < len - 1; i++) { + for (int j = i + 1; j < len; j++) { + + int a = Integer.parseInt(num.substring(0, i)); + int b = Integer.parseInt(num.substring(i, j)); + int c = Integer.parseInt(num.substring(j)); + + int sum = a + b + c; + + dfs(String.valueOf(sum), totalOdd); + } + } + } + + static int countOdd(String s) { + int cnt = 0; + for (char c : s.toCharArray()) { + if ((c - '0') % 2 == 1) cnt++; + } + return cnt; + } +} +```