From cda8c73795d39b8d369d417577022c6f1f717c8c Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Mon, 1 Sep 2025 17:58:43 +0900 Subject: [PATCH] =?UTF-8?q?[20250901]=20BOJ=20/=20G3=20/=200=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...OJ 0 \353\247\214\353\223\244\352\270\260" | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 "0224LJH/202509/01 BOJ 0 \353\247\214\353\223\244\352\270\260" diff --git "a/0224LJH/202509/01 BOJ 0 \353\247\214\353\223\244\352\270\260" "b/0224LJH/202509/01 BOJ 0 \353\247\214\353\223\244\352\270\260" new file mode 100644 index 00000000..32107bb6 --- /dev/null +++ "b/0224LJH/202509/01 BOJ 0 \353\247\214\353\223\244\352\270\260" @@ -0,0 +1,119 @@ +```java +import java.io.IOException; +import java.math.BigInteger; +import java.io.*; +import java.util.*; + + +public class Main { + + static int cnt,target,ans; + static int[] arr; + static List list; + static String[] decide; + static StringBuilder sb = new StringBuilder(); + + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + + } + + public static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + cnt = Integer.parseInt(br.readLine()); + arr = new int[cnt]; + + + for (int i = 0; i < cnt; i++) { + arr[i] = Integer.parseInt(br.readLine()); + } + } + + public static void process() throws IOException { + for (int tc = 0; tc < cnt; tc++) { + ans = 0; + target = arr[tc]; + decide = new String[target]; + list = new ArrayList<>(); + list.add(1); + + dfs(1); + + if (ans != 0) sb.append("\n"); + } + } + + public static void dfs(int num) { + if (num == target) { + + calculate(); + + return; + } + + + int nNum = num+1; + int temp = list.get(list.size()-1); + + + list.remove(list.size()-1); + decide[num-1] = " "; + + if (temp < 0) { + list.add(temp*10 - num - 1); + } else { + list.add(temp*10 + num + 1); + } + + dfs(num+1); + list.remove(list.size()-1); + list.add(temp); + + + + list.add(num+1); + decide[num-1] = "+"; + dfs(num+1); + list.remove(list.size()-1); + + list.add((num+1)*(-1)); + decide[num-1] = "-"; + dfs(num+1); + list.remove(list.size()-1); + + + + + + + + } + + public static void calculate() { + int res = 0; + + for (int n: list) { + res += n; + } + + if (res == 0) { + ans++; + sb.append(1); + for (int i = 1; i < target; i++) { + sb.append(decide[i-1]).append(i+1); + } + sb.append("\n"); + } + } + + + + public static void print() { + System.out.println(sb.toString()); + } +} + +```