From 5fb94053367e30383bf1d8f4960f1973eaca36a6 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Sun, 23 Nov 2025 07:56:56 +0700 Subject: [PATCH] =?UTF-8?q?[20251123]=20BOJ=20/=20G5=20/=20=ED=99=80?= =?UTF-8?q?=EC=88=98=20=ED=99=80=EB=A6=AD=20=ED=98=B8=EC=84=9D=20/=20?= =?UTF-8?q?=EC=9D=B4=EC=A4=80=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\353\246\255 \355\230\270\354\204\235.md" | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 "JHLEE325/202511/23 BOJ G5 \355\231\200\354\210\230 \355\231\200\353\246\255 \355\230\270\354\204\235.md" 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; + } +} +```