From 072cc76fa3809bd00c7298b7b6cd264e79b706e1 Mon Sep 17 00:00:00 2001 From: zinnnn37 Date: Sat, 15 Nov 2025 21:41:03 +0900 Subject: [PATCH] =?UTF-8?q?[20251115]=20PGM=20/=20LV2=20/=20=ED=83=80?= =?UTF-8?q?=EA=B2=9F=20=EB=84=98=EB=B2=84=20/=20=EA=B9=80=EB=AF=BC?= =?UTF-8?q?=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\352\262\237 \353\204\230\353\262\204.md" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "zinnnn37/202511/15 PGM LV2 \355\203\200\352\262\237 \353\204\230\353\262\204.md" diff --git "a/zinnnn37/202511/15 PGM LV2 \355\203\200\352\262\237 \353\204\230\353\262\204.md" "b/zinnnn37/202511/15 PGM LV2 \355\203\200\352\262\237 \353\204\230\353\262\204.md" new file mode 100644 index 00000000..bc644add --- /dev/null +++ "b/zinnnn37/202511/15 PGM LV2 \355\203\200\352\262\237 \353\204\230\353\262\204.md" @@ -0,0 +1,29 @@ +```java +public class PGM_LV2_타겟_넘버 { + + private static int target, len, ans; + private static int[] nums; + + private static void dfs(int start, int sum) { + if (start == len) { + if (sum == target) ans++; + return; + } + + dfs(start + 1, sum - nums[start]); + dfs(start + 1, sum + nums[start]); + } + + public int solution(int[] n, int t) { + target = t; + nums = n; + len = n.length; + ans = 0; + + dfs(0, 0); + + return ans; + } + +} +``` \ No newline at end of file