From fa466a4a61a5f1e895a9118de63b8d5cbb85aad8 Mon Sep 17 00:00:00 2001 From: HeeGyeong Date: Thu, 6 Feb 2025 10:53:41 +0900 Subject: [PATCH 001/177] =?UTF-8?q?[10430=20=EB=82=98=EB=A8=B8=EC=A7=80=20?= =?UTF-8?q?-=2025.02.06]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ ..._\353\202\230\353\250\270\354\247\200.java" | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 "2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" diff --git a/.gitignore b/.gitignore index 524f096..3b6a887 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* replay_pid* + +.vscode/ diff --git "a/2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" "b/2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" new file mode 100644 index 0000000..502dfe8 --- /dev/null +++ "b/2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" @@ -0,0 +1,18 @@ +import java.util.Scanner; + +public class BOJ_10430_나머지 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + int A = sc.nextInt(); + int B = sc.nextInt(); + int C = sc.nextInt(); + + System.out.println((A + B) % C); + System.out.println(((A % C) + (B % C)) % C); + System.out.println((A * B) % C); + System.out.println(((A % C) * (B % C)) % C); + + sc.close(); + } +} \ No newline at end of file From f2826119d1c926c5a67831477ebded09c0fafcd2 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sat, 8 Feb 2025 19:55:20 +0900 Subject: [PATCH 002/177] [4375 1 - 25.02.08] --- "2\354\233\224/HeeGyeong/BOJ_4375_1.java" | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "2\354\233\224/HeeGyeong/BOJ_4375_1.java" diff --git "a/2\354\233\224/HeeGyeong/BOJ_4375_1.java" "b/2\354\233\224/HeeGyeong/BOJ_4375_1.java" new file mode 100644 index 0000000..e291ea5 --- /dev/null +++ "b/2\354\233\224/HeeGyeong/BOJ_4375_1.java" @@ -0,0 +1,27 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_4375_1 { + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String line; + + while ((line = br.readLine()) != null && !line.isEmpty()) { + int inputNum = Integer.parseInt(line); + int digit = 1; + int only1Num = 1; + + while (only1Num % inputNum != 0) { + only1Num = ((only1Num * 10) + 1) % inputNum; + digit += 1; + } + + System.out.println(digit); + + } + + } + +} From 03e150d6078534ef7ecabc5c23209c002d2f0ed8 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:09:58 +0900 Subject: [PATCH 003/177] =?UTF-8?q?=ED=8F=B4=EB=8D=94=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.DS_Store" | Bin ...10430_\353\202\230\353\250\270\354\247\200.java" | 0 .../HeeGyeong/BOJ_4375_1.java" | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename "2\354\233\224/.DS_Store" => "2\354\233\224 1\354\243\274\354\260\250/.DS_Store" (100%) rename "2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" => "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" (100%) rename "2\354\233\224/HeeGyeong/BOJ_4375_1.java" => "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_4375_1.java" (100%) diff --git "a/2\354\233\224/.DS_Store" "b/2\354\233\224 1\354\243\274\354\260\250/.DS_Store" similarity index 100% rename from "2\354\233\224/.DS_Store" rename to "2\354\233\224 1\354\243\274\354\260\250/.DS_Store" diff --git "a/2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" similarity index 100% rename from "2\354\233\224/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" rename to "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_10430_\353\202\230\353\250\270\354\247\200.java" diff --git "a/2\354\233\224/HeeGyeong/BOJ_4375_1.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_4375_1.java" similarity index 100% rename from "2\354\233\224/HeeGyeong/BOJ_4375_1.java" rename to "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_4375_1.java" From fcbe017adb24f8577b971bb2710cf19bbfcceced Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:11:34 +0900 Subject: [PATCH 004/177] =?UTF-8?q?[1037=20=EC=95=BD=EC=88=98=20-=2025.02.?= =?UTF-8?q?09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_1037_\354\225\275\354\210\230.java" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1037_\354\225\275\354\210\230.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1037_\354\225\275\354\210\230.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1037_\354\225\275\354\210\230.java" new file mode 100644 index 0000000..3e91cac --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1037_\354\225\275\354\210\230.java" @@ -0,0 +1,28 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; +import java.io.IOException; + +/** + * N은 항상 32비트 부호있는 정수로 표현할 수 있으므로 int형 안에서 처리 가능함. + * 양수 A는 진짜 약수 중 최솟값과 최대값을 곱한 값이다. + */ +public class BOJ_1037_약수 { + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + StringTokenizer st = new StringTokenizer(br.readLine()); + int[] aliquotArr = new int[N]; + for (int idx = 0; idx < N; idx++) { + aliquotArr[idx] = Integer.parseInt(st.nextToken()); + } + + Arrays.sort(aliquotArr); + System.out.println(aliquotArr[0] * aliquotArr[N-1]); + + } + +} From d95861fc3751000e69307c486f24c5c98533e1c3 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:12:19 +0900 Subject: [PATCH 005/177] =?UTF-8?q?[17427=20=EC=95=BD=EC=88=98=EC=9D=98?= =?UTF-8?q?=ED=95=A92=20-=2025.02.09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\210\230\354\235\230\355\225\2512.java" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17427_\354\225\275\354\210\230\354\235\230\355\225\2512.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17427_\354\225\275\354\210\230\354\235\230\355\225\2512.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17427_\354\225\275\354\210\230\354\235\230\355\225\2512.java" new file mode 100644 index 0000000..41740f6 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17427_\354\225\275\354\210\230\354\235\230\355\225\2512.java" @@ -0,0 +1,21 @@ +import java.util.Scanner; + +/** + * idea: g(N)는 x = 1,2,3,4 ...N에서 (N/x)*x의 값을 모두 더한것과 같다. + * 유의사항: N이 최대 10^6이므로 오버플로우 방지를 위해 long타입으로 계산해야 한다. + */ +public class BOJ_17427_약수의합2 { + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + long result = 0; + + for (int x = 1; x <= N; x++) { + result += (long) (N / x) * x; + } + System.out.println(result); + } +} + + From db0d20951f4b674a63888b23bc2c0ce756164414 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:12:34 +0900 Subject: [PATCH 006/177] =?UTF-8?q?[17425=20=EC=95=BD=EC=88=98=EC=9D=98?= =?UTF-8?q?=ED=95=A9=20-=2025.02.09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\210\230\354\235\230\355\225\251.java" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17425_\354\225\275\354\210\230\354\235\230\355\225\251.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17425_\354\225\275\354\210\230\354\235\230\355\225\251.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17425_\354\225\275\354\210\230\354\235\230\355\225\251.java" new file mode 100644 index 0000000..97d3d1b --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_17425_\354\225\275\354\210\230\354\235\230\355\225\251.java" @@ -0,0 +1,41 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; + +/** + * [idea] + * - 17427_약수의합2 문제가 여러개 주어지는 문제 + * - 일반 반복문으로 풀면 중복되는 계산이 많아서 시간초과나므로 + * f(x)와 g(x)값을 미리 구해서 저장해 놓아야 함. + * 유의사항: Scanner로 입력값 받으면 시간초과로 통과 못함. + */ +public class BOJ_17425_약수의합 { + public static void main(String[] args) throws IOException{ + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + int T = Integer.parseInt(br.readLine()); + int MAX_N = 1_000_000; + long[] fxResult = new long[MAX_N+1]; + long[] gxResult = new long[MAX_N + 1]; + + Arrays.fill(fxResult, 1); + + for (int x = 2; x <= MAX_N; x++) { + for (int y = 1; x*y <= MAX_N; y++) { + fxResult[x*y] += x; + } + } + + for (int x = 1; x <= MAX_N; x++) { + gxResult[x] = gxResult[x - 1] + fxResult[x]; + } + + for (int i = 0; i < T; i++) { + int N = Integer.parseInt(br.readLine()); + sb.append(gxResult[N] + "\n"); + } + System.out.println(sb); + } +} \ No newline at end of file From 55501bb82b37fc9b6b83926c9b274baa3a6fbe41 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:13:06 +0900 Subject: [PATCH 007/177] =?UTF-8?q?[2609=20=EC=B5=9C=EB=8C=80=EA=B3=B5?= =?UTF-8?q?=EC=95=BD=EC=88=98=EC=99=80=20=EC=B5=9C=EC=86=8C=EA=B3=B5?= =?UTF-8?q?=EB=B0=B0=EC=88=98=20-=2025.02.09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\263\265\353\260\260\354\210\230.java" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_2609_\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_2609_\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_2609_\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.java" new file mode 100644 index 0000000..e4bd8f4 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_2609_\354\265\234\353\214\200\352\263\265\354\225\275\354\210\230\354\231\200\354\265\234\354\206\214\352\263\265\353\260\260\354\210\230.java" @@ -0,0 +1,35 @@ +import java.util.Scanner; +import java.util.Set; +import java.util.HashSet; + +public class BOJ_2609_최대공약수와최소공배수 { + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int A = sc.nextInt(); + int B = sc.nextInt(); + Set aAliquotSet = getAliquot(A); + Set bAliquotSet = getAliquot(B); + + aAliquotSet.retainAll(bAliquotSet); + int gcd = aAliquotSet.stream().max(Integer::compare).orElse(1); //최대공약수 + int lcm = (A * B) / gcd; // 최소공배수 + + System.out.println(gcd); + System.out.println(lcm); + } + + public static Set getAliquot(int x) { + Set aliquotSet = new HashSet<>(); + int sqrt = (int) Math.sqrt(x); + for (int num = 1; num <= sqrt; num++) { + if (x % num == 0) { + aliquotSet.add(num); + aliquotSet.add(x / num == num ? 0 : x / num); + } + } + return aliquotSet; + } +} + + From 056c43c342e843c22eac08732891ed9d27728519 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:13:29 +0900 Subject: [PATCH 008/177] =?UTF-8?q?[1978=20=EC=86=8C=EC=88=98=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=20-=2025.02.09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\210\230\354\260\276\352\270\260.java" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1978_\354\206\214\354\210\230\354\260\276\352\270\260.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1978_\354\206\214\354\210\230\354\260\276\352\270\260.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1978_\354\206\214\354\210\230\354\260\276\352\270\260.java" new file mode 100644 index 0000000..eed5325 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1978_\354\206\214\354\210\230\354\260\276\352\270\260.java" @@ -0,0 +1,50 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.StringTokenizer; + +public class BOJ_1978_소수찾기 { + public static void main(String[] args) throws IOException{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + StringTokenizer st = new StringTokenizer(br.readLine()); + + Set nums = new HashSet<>(); + for (int idx = 0; idx < N; idx++) { + nums.add(Integer.parseInt(st.nextToken())); + } + + Set primeNums = getPrimeNum(1000); + + nums.retainAll(primeNums); // 교집합 구함 + System.out.println(nums.size()); + + } + + // 에라토스테네스의 체 + private static Set getPrimeNum(int maxNum) { + boolean[] isPrime = new boolean[maxNum + 1]; + Arrays.fill(isPrime, true); + isPrime[0] = false; + isPrime[1] = false; + + for (int num = 2; num * num <= maxNum; num++) { + if (isPrime[num]) { + for (int n = num * num; n <= maxNum; n += num) { + isPrime[n] = false; // 배수를 제거 + } + } + } + + Set primes = new HashSet<>(); + for (int i = 2; i <= maxNum; i++) { + if (isPrime[i]) { + primes.add(i); + } + } + return primes; + } +} From 3851d9ec40acce5da89fc746f3d14e215a68f78b Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:13:47 +0900 Subject: [PATCH 009/177] =?UTF-8?q?[1929=20=EC=86=8C=EC=88=98=EA=B5=AC?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20-=2025.02.09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\265\254\355\225\230\352\270\260.java" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1929_\354\206\214\354\210\230\352\265\254\355\225\230\352\270\260.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1929_\354\206\214\354\210\230\352\265\254\355\225\230\352\270\260.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1929_\354\206\214\354\210\230\352\265\254\355\225\230\352\270\260.java" new file mode 100644 index 0000000..ebb7f90 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_1929_\354\206\214\354\210\230\352\265\254\355\225\230\352\270\260.java" @@ -0,0 +1,53 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.StringTokenizer; + +public class BOJ_1929_소수구하기 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + StringBuilder sb = new StringBuilder(); + int M = Integer.parseInt(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + + + + List primeNums = getPrimeNum(1_000_000); + + for (int num : primeNums) { + if (num >= M && num <= N) { + sb.append(num + "\n"); + } + } + System.out.println(sb); + + } + + // 에라토스테네스의 체 + private static List getPrimeNum(int maxNum) { + boolean[] isPrime = new boolean[maxNum + 1]; + Arrays.fill(isPrime, true); + isPrime[0] = false; + isPrime[1] = false; + + for (int num = 2; num * num <= maxNum; num++) { + if (isPrime[num]) { + for (int n = num * num; n <= maxNum; n += num) { + isPrime[n] = false; // 배수 제거 + } + } + } + + List primes = new ArrayList<>(); + for (int i = 2; i <= maxNum; i++) { + if (isPrime[i]) { + primes.add(i); + } + } + return primes; + } +} From cbde2f00ee506db4501f2c7ed7e29f3f8b74c04b Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:14:13 +0900 Subject: [PATCH 010/177] =?UTF-8?q?[6588=20=EA=B3=A8=EB=93=9C=EB=B0=94?= =?UTF-8?q?=ED=9D=90=EC=9D=98=20=EC=B6=94=EC=B8=A1=20-=2025.02.09]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\230\354\266\224\354\270\241.java" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230\354\266\224\354\270\241.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230\354\266\224\354\270\241.java" "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230\354\266\224\354\270\241.java" new file mode 100644 index 0000000..c3c673c --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/HeeGyeong/BOJ_6588_\352\263\250\353\223\234\353\260\224\355\235\220\354\235\230\354\266\224\354\270\241.java" @@ -0,0 +1,51 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; + +public class BOJ_6588_골드바흐의추측 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + boolean[] isPrime = getPrimeNum(1_000_000); + + while (true) { + int n = Integer.parseInt(br.readLine()); + if (n == 0) + break; + + boolean flag = false; + + for (int a = 3; a <= n / 2; a += 2) { + if (isPrime[a] && isPrime[n - a]) { + sb.append(n).append(" = ").append(a).append(" + ").append(n - a).append("\n"); + flag = true; + break; + } + } + + if (!flag) + sb.append("Goldbach's conjecture is wrong.\n"); + } + + System.out.println(sb); + + } + + // 에라토스테네스의 체 + private static boolean[] getPrimeNum(int maxNum) { + boolean[] isPrime = new boolean[maxNum + 1]; + Arrays.fill(isPrime, true); + isPrime[0] = false; + isPrime[1] = false; + + for (int num = 2; num * num <= maxNum; num++) { + if (isPrime[num]) { + for (int n = num * num; n <= maxNum; n += num) { + isPrime[n] = false; // 배수 제거 + } + } + } + return isPrime; + } +} From a6b4fe318f123b886e7aab496137cebcdc96490f Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 9 Feb 2025 23:32:16 +0900 Subject: [PATCH 011/177] =?UTF-8?q?Delete=202=EC=9B=94=201=EC=A3=BC?= =?UTF-8?q?=EC=B0=A8/.DS=5FStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../.DS_Store" | Bin 6148 -> 0 bytes 2 files changed, 1 insertion(+) delete mode 100644 "2\354\233\224 1\354\243\274\354\260\250/.DS_Store" diff --git a/.gitignore b/.gitignore index 3b6a887..9515523 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ hs_err_pid* replay_pid* .vscode/ +.DS_Store diff --git "a/2\354\233\224 1\354\243\274\354\260\250/.DS_Store" "b/2\354\233\224 1\354\243\274\354\260\250/.DS_Store" deleted file mode 100644 index 75ffad85b3176348799420f0b92196a1e5c0962c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJugH-6uo1Ytfep&y7w2hRC!nlDzTMle6#X)pF~!odyRh}{(@5HC(vmX5(z=H zegWss+}L^EEGiM1o6MZIGw04b_hffwhltd4XR}5$LPQlb#&Q*%CwQJ)A^K!w9H`71 zb96*olu~;>DX_ypa3DDF*Bs#A?jX(3E_Em&=l7d#tS9L@W_fGaLtA(=fhTW9vQukp zq^*53Z#&Prt+Za3bt?y>$2Zlp%PIeQt#tE;%>CWMn+IqX^|Wb$)@W-!$<=a!_jR0F za$HXpxp`Or_1*KW=>Np&D(}VdXs%Gh?wzy)-A&#@bGjd)`^wQ>;Cr+eIIjNqVe(1z zdwAU%zT$c6=%;0z04Xg|GhcyPLJj1)Utn=7EpmF*FmHi}(Q;3uYEEf(U;Ej18d+4*aSE E?`bCOpa1{> From a8f7d41bbb0cd03a3b96d09e70c782adfcca9f4e Mon Sep 17 00:00:00 2001 From: nnijgnus <76596376+k000927@users.noreply.github.com> Date: Mon, 10 Feb 2025 19:56:25 +0900 Subject: [PATCH 012/177] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index afdab13413556a83c7c43036349741174d659726..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKzi-n(6n@u+_L2aKQIR^H#KI7j#4SaL#SQMjz)~X^00ldaTC0vPiW4$KsXVuT z1S2CW{{R&OBjT??g7@w&s3nQi2?4q%z5DLR`|ihQ`_2adtTl?805t&M=!B&TCJT(( z$>(gv)DVxUJ_IzK>rUp}bi%o4TVWNj3jA#f(6?Iw*Qq+v`2ZKb-zTZ;M5&Choi>Me z==C4UFt>ygjq|?Ye2n^Ok`Eh=Z)|0?bZu>&uk$K@9URGVFbs#IycG^!Qt6qLX*A1+ z(etD`Zr3&*%WN1XS$CiaN!-PdS1*z*mgANjWpS>!fo|YsUT)VmCzIXn`*q>&JebzS z9ovm-?{hbpnaV7GI^?I4-EG!Wj74Y;0!Yh^@#IM8sS`txG*3+Yz7_K z>(6>x7T1%$Z$#p^@{>=M_vd@dW8*8w_K&VM{@Y-Xr7}CjF=;Jp;GTa40q*DTU+&Hp ziS@Zl-q7W5$g?VX@$Z(VpNh-K~HQGgyl8n0@!sa3!#U={eK0PPO~ozOE_ zXjEGVCh7`+Si)*$n5W+b;s}GD!9pXppfOEF)Kq4!7);Z#UYIz~V4+ddftkw(Gb1x| zLt$!k>|dyGV4g;sS_P~Emlasm#TuRe`^)eDmr1r{6|f5YR|>F_ANVa?k~v%F7Ds2T uK!1ZyMsbBkMZv@z$0|cd@g}-5Y!j40^b8gnu?Efl2q+nBViowK3j74SzLG-# From bedada68ca40d1ba0c90380b5c6db932676a11fa Mon Sep 17 00:00:00 2001 From: nnijgnus <76596376+k000927@users.noreply.github.com> Date: Mon, 10 Feb 2025 19:56:35 +0900 Subject: [PATCH 013/177] =?UTF-8?q?Delete=202=EC=9B=94=201=EC=A3=BC?= =?UTF-8?q?=EC=B0=A8/.DS=5FStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.DS_Store" | Bin 10244 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "2\354\233\224 1\354\243\274\354\260\250/.DS_Store" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/.DS_Store" "b/2\354\233\224 1\354\243\274\354\260\250/.DS_Store" deleted file mode 100644 index 5499a5da20d6019028f29d420b4b67249caea872..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMeQXp(6rZ>KV3!rUMM{qXy{qM$B1c;a4T9HeE3^e#xR$njmAl)e-LTy~ZueTS zsi~iTfblP*Vl*b2`2CeA1pUK*j0lM#fi$QX@gtF#=s#%UA7a!uJA3Wjbs?Ph`Ltj#yDEWrm~4U9{F|7+Ng-9F6TzmEk^VR->U? zQB_xxwty-t2-)4O>asB$Hd4B5+OiSG;00djlYAp1HFc}10@bx^N2>xO_0_?uKy6Lk z=%~P#RIXgNz3+fFs2fM@xf5_+A!G)tPn1X9HIvP_7Q>lRoQtWn{#B8#vNr2 zH8S($txTKeV%j{ybWxn)>+I^>(cRN0Nhwp=u4qw99a5U2mSXlvMJ8ISC2r^)No5GF z)Ezgp)S!->;&@bxrx2_(Xj(*lfT80_L(@78Q?*n>@9nXaLl))Hjv1LOXpQAT(+{detr1<)~(}3Qt?btEScRsq?&3>Q+lIj zT+wA!@9!E`Wouw3E|6}i`&A_=2*psOR2qqkchv5-;6ds2s;Td=qj=@XtCcFi2!@KY?dda+}%AxpY+aW^2Ul!Ma=6nM2O|hI`pPp!^#*ZER_6 zyJZ9Ft2=23-8HLZc4>gd)!Ow96AsAyHSMCAu5WvLR-D-0Zbw(Hr~2lU&7CKf`@1k4 zltZ}znhsoP8Vyf=oT4klO21Tq0mG_`#3g>I5QBwPm-|=vC633yw824twJ7Cb1PbGG z%jWoyxd!6}Y+k*%PL%R776rSyK`a*~BCtx>-{hBQWV!jct;oN0?=$2)`4Zjx7j*Bx zAP=3o6augag6PZ}AOsE21kJD&I$#?_Y^UyneGr2<7#Z2no; zo4xJV)vTu5{+j=|?Puwfx#4FqT($6&XE}2)lM8t*jLQ;c^^vo9JpOM} z@YjZKd%B4I*$W8gau#q3-bJq|m`vRo>QDXT=;nf()bDyY7ae&LVPB6(KRTjHzanKi zB3P(LYlb6E!Mo~_(`Tk0p&#!1aYBzNxJf;(hjY=Rfb`-wFoSF-YK{ieb2P|6y39R; zn>p*er*?hs%sLA(IbU~#%S>@PUh*v9S>U#`KpxXNK=1#Xul@c1wzQ3>v}b|a#R8Du z6ln^hw&^2yuHy8rJ%D*1W|}B&j8R(z3;Q}AseK)f6?z@N1T)1tR~7bi$Y~p6)D}mK aEsm7k=Kt>>18#{6HShfIo&Rs%`TrkLK*$mR From 2142c3ecd9d9369f413c0410ed84df05831d6f78 Mon Sep 17 00:00:00 2001 From: EUNJAE1012 <146701894+EUNJAE1012@users.noreply.github.com> Date: Mon, 10 Feb 2025 21:33:38 +0900 Subject: [PATCH 014/177] =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EUNJAE/BOJ1037/Main.java" | 45 +++++++++ .../EUNJAE/BOJ10430/Main.java" | 41 +++++++++ .../EUNJAE/BOJ17425/Main.java" | 91 +++++++++++++++++++ .../EUNJAE/BOJ17427/Main.java" | 48 ++++++++++ .../EUNJAE/BOJ1929/Main.java" | 66 ++++++++++++++ .../EUNJAE/BOJ1978/Main.java" | 59 ++++++++++++ .../EUNJAE/BOJ2609/Main.java" | 48 ++++++++++ .../EUNJAE/BOJ4375/Main.java" | 58 ++++++++++++ .../EUNJAE/BOJ6588/Main.java" | 69 ++++++++++++++ 9 files changed, 525 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ1037/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ10430/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ17425/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ17427/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ1929/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ1978/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ2609/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ4375/Main.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ6588/Main.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ1037/Main.java" "b/2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ1037/Main.java" new file mode 100644 index 0000000..b37a445 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/EUNJAE/BOJ1037/Main.java" @@ -0,0 +1,45 @@ +package BOJ1037; + + +/* + * 문제 +양수 A가 N의 진짜 약수가 되려면, N이 A의 배수이고, A가 1과 N이 아니어야 한다. 어떤 수 N의 진짜 약수가 모두 주어질 때, N을 구하는 프로그램을 작성하시오. + +입력 +첫째 줄에 N의 진짜 약수의 개수가 주어진다. 이 개수는 50보다 작거나 같은 자연수이다. 둘째 줄에는 N의 진짜 약수가 주어진다. 1,000,000보다 작거나 같고, 2보다 크거나 같은 자연수이고, 중복되지 않는다. + +출력 +첫째 줄에 N을 출력한다. N은 항상 32비트 부호있는 정수로 표현할 수 있다. + +예제 입력 1 +2 +4 2 +예제 출력 1 +8 + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter (System.out)); + + + int numOfFactors = Integer.parseInt(br.readLine()); + StringTokenizer st = new StringTokenizer(br.readLine(), " "); + int[] factors = new int[numOfFactors]; + for(int i =0;ix + *f(A) 함수를 구현하고 + *반복문을 통해 g(x)를 구현한다? -> 느림 + *먼저 값을 다 찾아놓고, 접근 + * + */ + + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +public class Main { + static int MAX_SIZE =1_000_001; + static long[] F = new long[MAX_SIZE+1]; + static long[] G = new long[MAX_SIZE+1]; + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int T = Integer.parseInt(br.readLine()); + +// for (int index =1; index O(N^2) 의 방식 +// f(index); +// } + f(); //f 전처리-> O(NlogN) 가능 + + for (int index=1;index O(N^2) 의 방식 +// f(index); +// } + f(); //f 전처리-> O(NlogN) 가능 + + for (int index=1;index=MAX_SIZE) { + System.out.println("6이상 짝수만 입력하세요요"); + continue; + } + + for(int index =3; index<=n/2; index+=2) { //index가 n부터 n/2 까지보면서 + if (primes[index] && primes[n-index]) { + num2 = n-index; + num1 = index; + break; + + } + } + if(num1==0) { //그럴일은 없겠지만 골드바흐가 틀렸다면 + System.out.println("Goldbach's conjecture is wrong"); + } + + System.out.printf("%d = %d + %d\n",n,num1,num2); + } + } + + /* + * 최대 범위보다 작은 소수를 찾는 함수 + */ + static void FindPrimes() { + primes[2]= true; + for(int index =3; index < MAX_SIZE;index+=2) { + boolean isPrime = true; + + for(int sub =3; sub*sub<=index;sub+=2) { //에라토스테네스의체-> √index 까지만 확인 + if(index%sub==0) { //sub는 index의 약수인가요? + isPrime=false; //찾았다.. + break; + } + } + if(isPrime) { //약수가 없으면 그게 소수다. + primes[index] = true; +// System.out.println(index); + } + } + + } +} From 54cc16af9d74ce7f0be159e79565e37181e35d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Mon, 10 Feb 2025 21:42:04 +0900 Subject: [PATCH 015/177] =?UTF-8?q?[1107=20=EB=A6=AC=EB=AA=A8=EC=BB=A8=20-?= =?UTF-8?q?=2025.02.10]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ1107/Main.java" | 210 ++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1107/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1107/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1107/Main.java" new file mode 100644 index 0000000..c2cf3cd --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1107/Main.java" @@ -0,0 +1,210 @@ +package BOJ1107; + +/* + * 문제 리모컨 +수빈이는 TV를 보고 있다. 수빈이는 채널을 돌리려고 했지만, 버튼을 너무 세게 누르는 바람에, 일부 숫자 버튼이 고장났다. + +리모컨에는 버튼이 0부터 9까지 숫자, +와 -가 있다. +를 누르면 현재 보고있는 채널에서 +1된 채널로 이동하고, -를 누르면 -1된 채널로 이동한다. +채널 0에서 -를 누른 경우에는 채널이 변하지 않고, 채널은 무한대 만큼 있다. + +수빈이가 지금 이동하려고 하는 채널은 N이다. 어떤 버튼이 고장났는지 주어졌을 때, 채널 N으로 이동하기 위해서 버튼을 최소 몇 번 눌러야하는지 구하는 프로그램을 작성하시오. + +수빈이가 지금 보고 있는 채널은 100번이다. + +입력 +첫째 줄에 수빈이가 이동하려고 하는 채널 N (0 ≤ N ≤ 500,000)이 주어진다. + 둘째 줄에는 고장난 버튼의 개수 M (0 ≤ M ≤ 10)이 주어진다. + 고장난 버튼이 있는 경우에는 셋째 줄에는 고장난 버튼이 주어지며, 같은 버튼이 여러 번 주어지는 경우는 없다. + +출력 +첫째 줄에 채널 N으로 이동하기 위해 버튼을 최소 몇 번 눌러야 하는지를 출력한다. + +예제 입력 1 +5457 +3 +6 7 8 +예제 출력 1 +6 + + +idea-> 한자리씩 비교하자 + +if want 54572 +but 5 ,2 broken +-> 4 or 6 +if choose 4 -> 4XXXX i will choice Largest num as X : 49999 -> ansS =4573 +if choose 6 -> 6XXXX i will choice Smallest num as X : 60000 -> ansL = 5428 +ans = Min(ansS, ansL) +만약, 4,6도 고장이라면,? 3,7을 비교-> 더 차이가 작은 쪽으로 사용 + + + + */ +//import java.io.BufferedReader; +//import java.io.BufferedWriter; +//import java.io.InputStreamReader; +//import java.io.OutputStreamWriter; +//import java.util.StringTokenizer; +// +//public class Main { +// static boolean[] broken = new boolean[10]; +// public static void main(String[] args) throws Exception { +// BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); +// BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); +// +// String strN = (br.readLine()); //목표치 +// int N = Integer.parseInt(strN); +// int len = strN.length(); +// int M = Integer.parseInt(br.readLine()); +// StringTokenizer st = new StringTokenizer(br.readLine()," "); +// +// for(int index =0; index=0;i--) { +// if(!broken[i]) { +// largest = i; +// } +// } +// int ans = 0; +// //첫자리가 고장났는지 확인 +// int pointer = 0; +// int upcnt=0, downcnt=0; +// while(pointer =0;down--) { +// downcnt +=1; +// if(!broken[down]) { +// break; +// } +// } +// System.out.println("up: "+upcnt+" down : "+downcnt); +// if(upcnt > downcnt) { //낮은 숫자가 더 가까우면 +// while(pointer brokenButtons = new HashSet<>(); + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int targetChannel = Integer.parseInt(br.readLine()); // 이동하려는 채널 + int brokenCount = Integer.parseInt(br.readLine()); // 고장난 버튼 개수 + + if (brokenCount > 0) { + String[] brokenNums = br.readLine().split(" "); + for (String num : brokenNums) { + brokenButtons.add(Integer.parseInt(num)); + } + } + + // 초기값: +,- 버튼으로만 이동하는 경우 + int minPress = Math.abs(targetChannel - 100); + + // 모든 가능한 채널(0~999999) 탐색 + for (int i = 0; i <= 999999; i++) { + int len = getPressCount(i); + if (len > 0) { // 해당 숫자를 만들 수 있다면 + int pressCount = len + Math.abs(i - targetChannel); // 버튼 누른 횟수 + 이동 거리 + minPress = Math.min(minPress, pressCount); + } + } + + System.out.println(minPress); + } + + // 특정 숫자를 만들 수 있는지 확인하고, 만들 수 있다면 버튼 누르는 횟수를 반환 + static int getPressCount(int num) { + if (num == 0) return brokenButtons.contains(0) ? 0 : 1; + + int count = 0; + while (num > 0) { + if (brokenButtons.contains(num % 10)) return 0; // 고장난 숫자가 있으면 만들 수 없음 + count++; + num /= 10; + } + return count; + } +} + From f68e44c3c696f9ea7637ca671196898d4ce783e1 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 10 Feb 2025 22:52:41 +0900 Subject: [PATCH 016/177] =?UTF-8?q?[2309=20=EC=9D=BC=EA=B3=B1=20=EB=82=9C?= =?UTF-8?q?=EC=9F=81=EC=9D=B4=20-=2025.02.10]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\202\234\354\237\201\354\235\264.java" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2309_\354\235\274\352\263\261\353\202\234\354\237\201\354\235\264.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2309_\354\235\274\352\263\261\353\202\234\354\237\201\354\235\264.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2309_\354\235\274\352\263\261\353\202\234\354\237\201\354\235\264.java" new file mode 100644 index 0000000..8832bfb --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2309_\354\235\274\352\263\261\353\202\234\354\237\201\354\235\264.java" @@ -0,0 +1,44 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; + +/** + * idea: 9개의 원소에서 7개를 고르는 것은 9C7=36으로 그 경우의 수가 적으므로 완전탐색이 가능하다. + * 9C7=9C2이므로 입력받을 때 9개 요소의 합을 같이 구하고, + * 서로 다른 원소를 2개씩 빼서 7개 요소의 합이 100이 되는 경우를 확인한다. + */ + +public class BOJ_2309_일곱난쟁이 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + + int[] heights = new int[9]; + int heightSum = 0; + + for (int idx = 0; idx < 9; idx++) { + heights[idx] = Integer.parseInt(br.readLine()); + heightSum += heights[idx]; + } + + Arrays.sort(heights); + + for (int excl1 = 0; excl1 < 9; excl1++) { + for (int excl2 = excl1; excl2 < 9; excl2++) { + if ((heightSum - heights[excl1] - heights[excl2]) == 100) { + + for(int idx = 0; idx < 9; idx++) { + if (idx != excl1 && idx != excl2) { + sb.append(heights[idx] + "\n"); + } + } + + System.out.println(sb); + return; + } + } + } + } +} \ No newline at end of file From 4748b5ae4c23fbb2333697ab6481ab5ab2637188 Mon Sep 17 00:00:00 2001 From: munncoding Date: Tue, 11 Feb 2025 14:51:18 +0900 Subject: [PATCH 017/177] =?UTF-8?q?[2309=20=EC=9D=BC=EA=B3=B1=20=EB=82=9C?= =?UTF-8?q?=EC=9F=81=EC=9D=B4=20-=2025.02.11]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.DS_Store" | Bin 6148 -> 0 bytes .../ChulHyeon/.idea/.gitignore" | 8 +++ .../ChulHyeon/BOJ2309/Main.java" | 55 ++++++++++++++++++ .../production/ChulHyeon/.idea/.gitignore" | 8 +++ SSAFY-AlgorithmStudy.iml | 13 ----- .../SSAFY-AlgorithmStudy/.idea/.gitignore | 8 +++ .../out/production/ChulHyeon/.idea/.gitignore | 8 +++ 7 files changed, 87 insertions(+), 13 deletions(-) delete mode 100644 "2\354\233\224 2\354\243\274\354\260\250/.DS_Store" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" delete mode 100644 SSAFY-AlgorithmStudy.iml create mode 100644 out/production/SSAFY-AlgorithmStudy/.idea/.gitignore create mode 100644 out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore diff --git "a/2\354\233\224 2\354\243\274\354\260\250/.DS_Store" "b/2\354\233\224 2\354\243\274\354\260\250/.DS_Store" deleted file mode 100644 index 1b27236e6a880d593fb6890e2b8fe86d86a45026..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c^3>-s>pfo8d_ZRqsRY)XyegHv`C{A2~QqWzM@8Z)KKZJ-bG)OdPEZMW` z^W18uIG+L7=CHp3)&Q1tM;txO&7Zr^?4mM8r1Kqjc*iqFyzbv-)#nq=y}~VCaKP}L z|1>;~<8Yp&tQ3#}Qa}nw0V(in1-$ptma9ZXDIf);z?TC4eQ0#YUN|Mjr-LCz0OEq_ zFs@^kAU01Bd*PJG49${COsdt0VM%AcRb4Nf5|a+A;lt`=s|m&8biThuIjkotN&zWw zs=#G#*WUkk^dIK`Q<8R4KnnaT1#Gds-)?xN>aDZOd9Q8s2fEjM(A~HW3PZGGVzgs! gyd7UhQPwqI^La0v5`)fs(24pPa9w0l;I9?<1SZTCQUCw| diff --git "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ2309/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ2309/Main.java" index ccab87e..8142dd8 100644 --- "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ2309/Main.java" +++ "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ2309/Main.java" @@ -1,4 +1,59 @@ package BOJ2309; +/* +20 +7 +23 +19 +10 +15 +25 +8 +13 +난쟁이 키의 합이 100이고 +7개의 난쟁이를 찾아 오름차순으로 배열 + */ + +import java.util.*; +import java.io.*; public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + ArrayList arr = new ArrayList(); + int sum = 0; + for(int i=0;i<9;i++) + { + int n = Integer.parseInt(br.readLine()); // 입력 받고 + arr.add(n); + sum += n; + } + // 2중 포문으로 + boolean flag = true; + for(int i=0;i<9;i++) + { + if(flag == false) + { + break; + } + for(int j=i+1;j<9;j++) + { + int x = arr.get(i); + int y = arr.get(j); + if(sum - x - y == 100) + { + flag = false; + arr.remove(j); + arr.remove(i); + break; + } + } + } + Collections.sort(arr); + for(int a : arr) + { + System.out.println(a); + } + } } diff --git "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/SSAFY-AlgorithmStudy.iml b/SSAFY-AlgorithmStudy.iml deleted file mode 100644 index c363066..0000000 --- a/SSAFY-AlgorithmStudy.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/out/production/SSAFY-AlgorithmStudy/.idea/.gitignore b/out/production/SSAFY-AlgorithmStudy/.idea/.gitignore new file mode 100644 index 0000000..96839f3 --- /dev/null +++ b/out/production/SSAFY-AlgorithmStudy/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml \ No newline at end of file diff --git a/out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore b/out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore new file mode 100644 index 0000000..96839f3 --- /dev/null +++ b/out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml \ No newline at end of file From fec03208d45b8893605d8cf37c56496093131541 Mon Sep 17 00:00:00 2001 From: munncoding Date: Tue, 11 Feb 2025 15:56:51 +0900 Subject: [PATCH 018/177] =?UTF-8?q?[3085=20=EC=82=AC=ED=83=95=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20-=2025.02.11]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/BOJ3085/Main.java" | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ3085/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ3085/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ3085/Main.java" new file mode 100644 index 0000000..a812d6c --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ3085/Main.java" @@ -0,0 +1,115 @@ +package BOJ3085; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.*; + +/* +가장 긴 행과 가장 긴 열 중 하나 선택가능 +1. 한 번 교환 가능 + + */ + +public class Main { + + static char[][] map; + + static int[] dr = {0,1}; + static int[] dc = {1,0}; + static int result = 0; + + static void changeAndCheck(int row, int col, char nowValue) + { + for(int i=0;i<2;i++) + { + int nextRow= row+dr[i]; + int nextCol= col+dc[i]; + // 범위 체크 + if(nextRow < 0 || nextRow >= map.length || nextCol < 0 || nextCol >= map.length) + continue; + // 다음꺼랑 다를 때만 교환 + if(nowValue != map[nextRow][nextCol]) + { + char tmp = map[row][col]; + map[row][col] = map[nextRow][nextCol]; + map[nextRow][nextCol] = tmp; + } + else // 안 다르면 교환 안함 + { + continue; + } + // 교환한 상태에서 + // 가장 긴 부분 찾기 - 1 행 + for(int r = 0; r Date: Tue, 11 Feb 2025 20:18:01 +0900 Subject: [PATCH 019/177] =?UTF-8?q?[15649=20N=EA=B3=BC=20M=20-=2025.02.11]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15649/Main.java" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15649/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15649/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15649/Main.java" new file mode 100644 index 0000000..3d27458 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15649/Main.java" @@ -0,0 +1,66 @@ +package BOJ15649; + + +/* + * 문제 N과 M (1) +자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. + +1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열 +입력 +첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +예제 출력 1 +1 +2 +3 + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.StringTokenizer; +public class Main { + static boolean[] visited; + static int[] ans; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + visited = new boolean[N+1]; + ans = new int[M]; + dfs(0,N,M); + } + + static void dfs(int depth,int N,int M) { +// System.out.println("depth" + " : "+depth); + if(depth==M) { + for(int i : ans) { + System.out.print(i+" "); + } + System.out.println(); + return; + } + for(int i=1; i<=N;i++) { + if(!visited[i]) { + visited[i]= true; + ans[depth] = i; + dfs(depth+1,N,M); + visited[i]= false; + } + } + + + + + } + +} From 853072c51926ccbd135605a4c0fd75e4d39b864b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Tue, 11 Feb 2025 20:18:57 +0900 Subject: [PATCH 020/177] =?UTF-8?q?[15650=20N=EA=B3=BC=20M=20(2)=20-=2025.?= =?UTF-8?q?02.11]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15650/Main.java" | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15650/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15650/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15650/Main.java" new file mode 100644 index 0000000..f179818 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15650/Main.java" @@ -0,0 +1,67 @@ +package BOJ15650; +/* + * 문제 +자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. + +1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열 +고른 수열은 오름차순이어야 한다. +입력 +첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +예제 출력 1 +1 +2 +3 + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.StringTokenizer; +public class Main { + static boolean[] visited; + static int[] ans; + static int N; + static int M; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + visited = new boolean[N+1]; + ans = new int[M]; + dfs(0,1); + } + + static void dfs(int depth,int idx) { +// System.out.println("depth" + " : "+depth); + if(depth==M) { + for(int i : ans) { + System.out.print(i+" "); + } + System.out.println(); + return; + } + for(int i=idx; i<=N;i++) { + if(!visited[i]) { + visited[i]= true; + ans[depth] = i; + dfs(depth+1,i); + visited[i]= false; + } + } + + + + + } + +} From ef88868e231f0bb70ddf31d4da9ac783312e7fb2 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Tue, 11 Feb 2025 23:56:17 +0900 Subject: [PATCH 021/177] =?UTF-8?q?3085=20=EC=82=AC=ED=83=95=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20-=2025.02.11]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\203\225\352\262\214\354\236\204.java" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_3085_\354\202\254\355\203\225\352\262\214\354\236\204.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_3085_\354\202\254\355\203\225\352\262\214\354\236\204.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_3085_\354\202\254\355\203\225\352\262\214\354\236\204.java" new file mode 100644 index 0000000..31987a2 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_3085_\354\202\254\355\203\225\352\262\214\354\236\204.java" @@ -0,0 +1,79 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +//백준 3085번 +public class BOJ_3085_사탕게임 { + static int N; + static char[][] board; + static int maxLength; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + board = new char[N][N]; + maxLength = 0; + + // 보드 입력받음 + for (int inputLine = 0; inputLine < N; inputLine++) { + board[inputLine] = br.readLine().toCharArray(); + } + + + // 모든 칸에서 스왑을 시도하며 최댓값 계산 + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + // 오른쪽과 교환 + if (j + 1 < N) { + swap(i, j, i, j + 1); + getMaxLength(); + swap(i, j, i, j + 1); + } + // 아래쪽과 교환 + if (i + 1 < N) { + swap(i, j, i + 1, j); + getMaxLength(); + swap(i, j, i + 1, j); + } + } + } + + System.out.println(maxLength); + + } + + + // 두 사탕 위치 바꿈. + private static void swap(int row1, int col1, int row2, int col2) { + char temp = board[row1][col1]; + board[row1][col1] = board[row2][col2]; + board[row2][col2] = temp; + } + + // 현재 보드 상태에서 행과 열로 가장 긴 연속 부분의 길이를 구한다. + private static void getMaxLength() { + for (int i = 0; i < N; i++) { + int rowCount = 1; + int colCount = 1; + for (int j = 1; j < N; j++) { + //행에서 최대 길이 + if (board[i][j] == board[i][j - 1]) { + rowCount++; + } else { + maxLength = Math.max(maxLength, rowCount); + rowCount = 1; + } + //열에서 최대 길이 + if (board[j][i] == board[j - 1][i]) { + colCount++; + } else { + maxLength = Math.max(maxLength, colCount); + colCount = 1; + } + } + maxLength = Math.max(maxLength, rowCount); + maxLength = Math.max(maxLength, colCount); + } + } + +} \ No newline at end of file From 1d38e42c99f515cb17d2989cf1bdce8009f25fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Wed, 12 Feb 2025 21:56:25 +0900 Subject: [PATCH 022/177] =?UTF-8?q?[9095=201,2,3=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=2025.02.12]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ9095/Main.java" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ9095/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ9095/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ9095/Main.java" new file mode 100644 index 0000000..1dded2c --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ9095/Main.java" @@ -0,0 +1,66 @@ +package BOJ9095; + +/* + * 문제 1,2,3 더하기 +정수 4를 1, 2, 3의 합으로 나타내는 방법은 총 7가지가 있다. 합을 나타낼 때는 수를 1개 이상 사용해야 한다. + +1+1+1+1 +1+1+2 +1+2+1 +2+1+1 +2+2 +1+3 +3+1 +정수 n이 주어졌을 때, n을 1, 2, 3의 합으로 나타내는 방법의 수를 구하는 프로그램을 작성하시오. + +입력 +첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 정수 n이 주어진다. n은 양수이며 11보다 작다. + +출력 +각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다. + +예제 입력 1 +3 +4 +7 +10 +예제 출력 1 +7 +44 +274 +1:1 = 1 | +2:2 = 1+1| 2 +3:4 = 1+1+1 | 1+2, 2+1 | 3 +4:7 = 1+3|, 2+2,1+1+2 | 1+2+1,2+1+1,3+1,1+1+1+1 +5:13 = 1+1+1+1+1 |1+1+1+2 * 4 |1+1+3 *3 , 2+2+1, *3 | 3+2, 2+3 | + +1,2,4,7,13 + +N을 만드는 법 : N-1 읆 만들고 1을 더한다. N-2를 만들고 2를 더한다. N-3을 더하고 3을 더한다. + + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +public class Main { + static int[] dp = new int[12]; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int T = Integer.parseInt(br.readLine()); + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i = 4; i<12;i++) { + dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; + } + for (int test_case = 1 ; test_case<=T;test_case++) { + int n = Integer.parseInt(br.readLine()); + bw.write(dp[n]+"\n"); + } + bw.flush(); + + } +} From b286ccbb89074ff6817a3b762a6598e3acbd5565 Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 13 Feb 2025 21:56:11 +0900 Subject: [PATCH 023/177] =?UTF-8?q?[2146=20=EB=8B=A4=EB=A6=AC=EA=B1=B4?= =?UTF-8?q?=EB=84=88=EA=B8=B0=20-=2025.02.13]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.idea/.gitignore" | 0 .../ChulHyeon/BOJ2146/Main.java" | 149 ++++++++++++++++++ .../SSAFY-AlgorithmStudy/.idea/.gitignore | 2 +- 3 files changed, 150 insertions(+), 1 deletion(-) rename "2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" => "A\355\230\225\353\214\200\353\271\204/.idea/.gitignore" (100%) create mode 100644 "A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" "b/A\355\230\225\353\214\200\353\271\204/.idea/.gitignore" similarity index 100% rename from "2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore" rename to "A\355\230\225\353\214\200\353\271\204/.idea/.gitignore" diff --git "a/A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" new file mode 100644 index 0000000..7a3dcd0 --- /dev/null +++ "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" @@ -0,0 +1,149 @@ +package BOJ2146; + +import javax.swing.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.LinkedList; +import java.util.Queue; +import java.util.StringTokenizer; + +class Pair{ + int row; + int col; + int dist; + + public Pair(int row, int col, int dist) { + this.row = row; + this.col = col; + this.dist = dist; + } +} + +public class Main { + // 지도 크기 + static int[][] inputMap = new int[101][101]; + static int n; // 초기에 입력받는 맵의 크기 + static int[][] island = new int[101][101]; // 섬의 번호를 넣을 배열 + + static int dr[] = {1,-1,0,0}; + static int dc[] = {0,0,1,-1}; + static boolean visit[][] = new boolean[101][101]; + + // 섬에 번호를 부여하는 함수 - dfs + static void checkIsland(int landNum, int nowR, int nowC) + { + visit[nowR][nowC] = true; + island[nowR][nowC] = landNum; + for(int i = 0; i < 4; i++) + { + int nextR = nowR + dr[i]; + int nextC = nowC + dc[i]; + // 범위 체크 + if(nextR < 0 || nextC < 0 || nextR >=n || nextC >=n) + continue; + // 방문 체크 + if(visit[nextR][nextC] == true) + continue; + if(inputMap[nextR][nextC] == 0) + continue; + checkIsland(landNum, nextR, nextC); + } + } + + static void initializeVisit() + { + for(int i=0;i q = new LinkedList<>(); + q.add(new Pair(nowR, nowC, 0)); // 초기화 한 번 해주고 + while(!q.isEmpty()) + { + Pair nowPair = q.poll(); + int nowRow = nowPair.row; + int nowCol = nowPair.col; + int nowDist = nowPair.dist; + for(int i = 0;i<4;i++) + { + int nextR = nowRow + dr[i]; + int nextC = nowCol + dc[i]; + // 범위 체크 + if(nextR < 0 || nextC < 0 || nextR >=n || nextC >=n) + continue; + // 방문 체크 + if(visit[nextR][nextC] == true) + continue; + // 다음 방향이 같은 섬인지 체크 + if(island[nextR][nextC] == islandNum) + continue; + // 다음이 육지라면 리턴 + if(island[nextR][nextC] != 0) + { + return nowDist; + } + if(island[nextR][nextC] == 0)// 다음이 바다라면 큐에 넣기 + { + visit[nextR][nextC] = true; + q.add(new Pair(nextR, nextC, nowDist+ 1)); + } + } + } + return Integer.MAX_VALUE; + } + + + + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + // 입력 + n = Integer.parseInt(br.readLine()); + for(int i = 0; i < n; i++) { + st = new StringTokenizer(br.readLine()); + for(int j=0;j Date: Thu, 13 Feb 2025 22:51:51 +0900 Subject: [PATCH 024/177] =?UTF-8?q?[1748=20=EC=88=98=20=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=EC=93=B0=EA=B8=B0=201=20-=2025.02.13]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ1748/Main.java" | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1748/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1748/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1748/Main.java" new file mode 100644 index 0000000..3d88527 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1748/Main.java" @@ -0,0 +1,70 @@ +package BOJ1748; +/* + * 문제 수 이어 쓰기 +1부터 N까지의 수를 이어서 쓰면 다음과 같이 새로운 하나의 수를 얻을 수 있다. + +1234567891011121314151617181920212223... + +이렇게 만들어진 새로운 수는 몇 자리 수일까? 이 수의 자릿수를 구하는 프로그램을 작성하시오. + +입력 +첫째 줄에 N(1 ≤ N ≤ 100,000,000)이 주어진다. + +출력 +첫째 줄에 새로운 수의 자릿수를 출력한다. + +예제 입력 1 +5 +예제 출력 1 +5 +예제 입력 2 +15 +예제 출력 2 +21 +예제 입력 3 +120 +예제 출력 3 +252 + +1~9 +1 N +10~99 +2 +100~999 +3 +1000~9999 +4 +5-> 1이 5개 +12 -> 2가 3개, 1이 9개 +138 -> 3이 39개, 2가 90개 1이 9개 +1234 -> 4가 235개 3이 900개,2가 90개 2가 1이9개 +120 -> 3이 21개, 2가 90개 1이 9개 + */ + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +public class Main { + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + int N = Integer.parseInt(br.readLine()); + + int length = 1; // 현재 자리수 + int count = 9; // 해당 자리수에서 가능한 숫자의 개수 + int total = 0; // 총 자릿수 합 + + int num = N; + + while (num > count) { + total += length * count; // 현재 자리수의 숫자 개수만큼 더함 + num -= count; // 남은 숫자 갱신 + length++; // 자리수 증가 + count *= 10; // 자리수 증가에 따른 숫자 개수 증가 +// System.out.println(length+":"+total+","+num); + } + + // 마지막 남은 자리수 처리 + total += length * num; + + System.out.println(total); + } +} From 353b0416bffb02cc687d6387119d0642e78e0539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Fri, 14 Feb 2025 23:41:12 +0900 Subject: [PATCH 025/177] =?UTF-8?q?[14500=20=ED=85=8C=ED=8A=B8=EB=A1=9C?= =?UTF-8?q?=EB=AF=B8=EB=85=B8=20-=2025.02.14]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ14500/Main.java" | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ14500/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ14500/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ14500/Main.java" new file mode 100644 index 0000000..351bd99 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ14500/Main.java" @@ -0,0 +1,93 @@ +package BOJ14500; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.StringTokenizer; + +public class Main { + static int[] dr = {-1,1,0,0}; //상하좌우 + static int[] dc = {0,0,-1,1}; + static int N,M; + static int[][] board; + static int total; + static boolean[][] visited; + static int ans = -1; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + board = new int[N][M]; + visited = new boolean[N][M]; + for(int i = 0;i=N || nc<0 || nc>=M) { + continue; + } + cnt++; + total += board[nr][nc]; + min = Math.min(min, board[nr][nc]); + } + if(cnt==4) { + total -= min; + } + ans = Math.max(ans, total); + } + + static void dfs(int cnt,int r,int c,int total,String a) { +// a+="("+r+","+c+") "; +// if(total>ans) { +// System.out.println("현재 "+cnt+"개째, 좌표: ("+a+") total : "+total); +// System.out.println("찾았다. "+total); +// } + + if(cnt==4) { + ans =Math.max(total, ans); + //4번째 블록까지 봤다면, 리턴 + return; + } + else { //4번째 블록을 안봤다면, 4방탐색후 안간 블록을 방문 + for(int d=0;d=N || nc<0 || nc>=M || visited[nr][nc]) continue; + else { + //아니라면 방문 + visited[nr][nc] = true; + dfs(cnt+1,nr,nc,total+board[nr][nc],a); + visited[nr][nc] = false; + } + } + } + } +} From 85ab5fe5a57adf7288230c5044055523eecfbb95 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sat, 15 Feb 2025 13:12:53 +0900 Subject: [PATCH 026/177] test --- .../YuRi/Yuri_1037.java" | 24 ++++++++++ .../YuRi/Yuri_10430.java" | 26 +++++++++++ .../YuRi/Yuri_17425.java" | 43 +++++++++++++++++ .../YuRi/Yuri_17427.java" | 22 +++++++++ .../YuRi/Yuri_1929.java" | 35 ++++++++++++++ .../YuRi/Yuri_1978.java" | 36 +++++++++++++++ .../YuRi/Yuri_2609.java" | 27 +++++++++++ .../YuRi/Yuri_4375.java" | 27 +++++++++++ .../YuRi/Yuri_6588.java" | 46 +++++++++++++++++++ 9 files changed, 286 insertions(+) create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_1037.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_10430.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_17425.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_17427.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_1929.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_1978.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_2609.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_4375.java" create mode 100644 "2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_6588.java" diff --git "a/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_1037.java" "b/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_1037.java" new file mode 100644 index 0000000..c72f2e5 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_1037.java" @@ -0,0 +1,24 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int t = Integer.parseInt(br.readLine()); + StringTokenizer st = new StringTokenizer(br.readLine()); + //StringBuilder sb = new StringBuilder(); + + int max = Integer.MIN_VALUE; + int min = Integer.MAX_VALUE; + + for(int i =0; i< t; i++) { + int now = Integer.parseInt(st.nextToken()); + max = Math.max(max, now); + min = Math.min(min, now); + } + + System.out.println(max*min); + } +} \ No newline at end of file diff --git "a/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_10430.java" "b/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_10430.java" new file mode 100644 index 0000000..090edcf --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_10430.java" @@ -0,0 +1,26 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Yuri_10430 { + + public static void main(String[] args) throws IOException { + int A, B, C; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String num = br.readLine(); + StringTokenizer st = new StringTokenizer(num," "); + A = Integer.parseInt(st.nextToken()); + B = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + + System.out.println((A+B)%C); + System.out.println(((A%C) + (B%C))%C); + System.out.println((A*B)%C); + System.out.println(((A%C)*(B%C))%C); + } + +} diff --git "a/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_17425.java" "b/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_17425.java" new file mode 100644 index 0000000..d454f88 --- /dev/null +++ "b/2\354\233\224 1\354\243\274\354\260\250/YuRi/Yuri_17425.java" @@ -0,0 +1,43 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static final int MAX_VALUE = 1_000_001; + public static void main(String[] args) throws Exception { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + //int N = Integer.parseInt(br.readLine()); + + + StringBuilder sb = new StringBuilder(); + int N = Integer.parseInt(br.readLine()); + //StringTokenizer st = new StringTokenizer(br.readLine()); + + long[] arr = new long[MAX_VALUE]; + long[] arr_sum = new long[MAX_VALUE]; + Arrays.fill(arr, 1); + + for(int i =2;i Date: Sat, 15 Feb 2025 13:49:01 +0900 Subject: [PATCH 027/177] =?UTF-8?q?[2309=20=EC=9D=BC=EA=B3=B1=20=EB=82=9C?= =?UTF-8?q?=EC=9F=81=EC=9D=B4=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_2309/Main.java" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_2309/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_2309/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_2309/Main.java" new file mode 100644 index 0000000..781b8f2 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_2309/Main.java" @@ -0,0 +1,26 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Yuri_2309 { + + public static void main(String[] args) throws IOException { + int A, B, C; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String num = br.readLine(); + StringTokenizer st = new StringTokenizer(num," "); + A = Integer.parseInt(st.nextToken()); + B = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + + System.out.println((A+B)%C); + System.out.println(((A%C) + (B%C))%C); + System.out.println((A*B)%C); + System.out.println(((A%C)*(B%C))%C); + } + +} From 9cb775130a12eb84aa3de2a3c9569681b81b8cec Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sat, 15 Feb 2025 13:50:01 +0900 Subject: [PATCH 028/177] =?UTF-8?q?[3085=20=EC=82=AC=ED=83=95=20=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_3085/Main.java" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_3085/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_3085/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_3085/Main.java" new file mode 100644 index 0000000..477e1f9 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_3085/Main.java" @@ -0,0 +1,26 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Yuri_3085 { + + public static void main(String[] args) throws IOException { + int A, B, C; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String num = br.readLine(); + StringTokenizer st = new StringTokenizer(num," "); + A = Integer.parseInt(st.nextToken()); + B = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + + System.out.println((A+B)%C); + System.out.println(((A%C) + (B%C))%C); + System.out.println((A*B)%C); + System.out.println(((A%C)*(B%C))%C); + } + +} From fc531fb4602c5b7a686d7b79779d7ccafe85e70c Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sat, 15 Feb 2025 13:50:49 +0900 Subject: [PATCH 029/177] =?UTF-8?q?[1476=20=EB=82=A0=EC=A7=9C=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_1476/Main.java" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1476/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1476/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1476/Main.java" new file mode 100644 index 0000000..4ad732e --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1476/Main.java" @@ -0,0 +1,25 @@ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int E,S,M; + + public static void main(String[] args) throws Exception { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()," "); + + E = Integer.parseInt(st.nextToken()); + S = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + int i=E; + while(true) { + if((i-S)%28 == 0 && (i-M)%19 == 0) break; + i+=15; + } + System.out.println(i); + } +} \ No newline at end of file From c7c6b6e9e42ce22765e5ccf61a7b27f3b37fc28b Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sat, 15 Feb 2025 15:57:04 +0900 Subject: [PATCH 030/177] =?UTF-8?q?[1107=20=EB=A6=AC=EB=AA=A8=EC=BB=A8=20-?= =?UTF-8?q?=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_1107/Main.java" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1107/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1107/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1107/Main.java" new file mode 100644 index 0000000..afadd68 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1107/Main.java" @@ -0,0 +1,49 @@ + + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +public class Main { + + public static void main(String[] args) throws Exception { + int N,M; + int result =0; + boolean[] isBreak = new boolean[10]; + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + N = Integer.parseInt(br.readLine()); + M = Integer.parseInt(br.readLine()); + + if(M>0) { + StringTokenizer st = new StringTokenizer(br.readLine()); + + for(int i=0;i Date: Sat, 15 Feb 2025 21:20:44 +0900 Subject: [PATCH 031/177] =?UTF-8?q?[1476=20=EB=82=A0=EC=A7=9C=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.idea/.gitignore" | 8 +++ .../ChulHyeon/BOJ1476/Main.java" | 31 ++++++++++ .../chulhyeonn/.gitignore" | 29 +++++++++ .../chulhyeonn/.idea/.gitignore" | 8 +++ .../chulhyeonn/src/BOJ1476/Main.java" | 60 +++++++++++++++++++ .../.idea/.gitignore" | 8 +++ 6 files changed, 144 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ1476/Main.java" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.gitignore" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.idea/.gitignore" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1476/Main.java" create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/out/production/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" "b/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ1476/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ1476/Main.java" new file mode 100644 index 0000000..64849a9 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/ChulHyeon/BOJ1476/Main.java" @@ -0,0 +1,31 @@ +package BOJ1476; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Scanner; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + st = new StringTokenizer(br.readLine()); + int E = Integer.parseInt(st.nextToken()); + int S = Integer.parseInt(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + + int result = 1; + while(true) + { + if(result % 15 == E && result % 28 == S && result % 19 == N) + { + break; + } + result++; + } + System.out.println(result); + } +} diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.gitignore" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.idea/.gitignore" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1476/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1476/Main.java" new file mode 100644 index 0000000..3d23e4e --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1476/Main.java" @@ -0,0 +1,60 @@ +package BOJ1476; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static final int MAXVALUE = 15 * 28 * 19; + + static boolean[][] arr = new boolean[3][MAXVALUE + 1]; + + public static void check(char type, int value) + { + if(type == 'E') + { + for(int i = value; i <= MAXVALUE; i = i + 15) + { + arr[0][i] = true; + } + } + if(type == 'S') + { + for(int i = value; i <= MAXVALUE; i = i + 28) + { + arr[1][i] = true; + } + } + if(type == 'M') + { + for(int i = value; i <= MAXVALUE; i = i + 19) + { + arr[2][i] = true; + } + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + st = new StringTokenizer(br.readLine()); + int E = Integer.parseInt(st.nextToken()); + int S = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + check('E',E); + check('S',S); + check('M',M); + + for(int i = 1; i <= MAXVALUE; i++) + { + if(arr[0][i]&&arr[1][i]&&arr[2][i]) + { + System.out.println(i); + break; + } + } + } +} \ No newline at end of file diff --git "a/2\354\233\224 2\354\243\274\354\260\250/out/production/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" "b/2\354\233\224 2\354\243\274\354\260\250/out/production/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/out/production/2\354\233\224 2\354\243\274\354\260\250/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml From 2f8368c55ca9af1cd364ebc735812bd1cfd16717 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sat, 15 Feb 2025 23:25:56 +0900 Subject: [PATCH 032/177] =?UTF-8?q?[1107=EB=A6=AC=EB=AA=A8=EC=BB=A8=20-=20?= =?UTF-8?q?25.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ1107/Main.java" | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1107/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1107/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1107/Main.java" new file mode 100644 index 0000000..86de00f --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1107/Main.java" @@ -0,0 +1,90 @@ +package BOJ1107; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args)throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + boolean[] ban = new boolean[10]; + // 입력 + int want = Integer.parseInt(br.readLine()); + int banCnt=Integer.parseInt(br.readLine()); + if(banCnt != 0) + { + String input = br.readLine(); + st = new StringTokenizer(input); + while(st.hasMoreTokens()) + { + int number = Integer.parseInt(st.nextToken()); + ban[number]=true; + } + } + // 1. want가 100 그대로일 경우 + if(want == 100){ + System.out.println(0); + return; + } + // 2. 다 고장나서 + - 로만 이동해야 할 경우 + if(banCnt == 10){ + System.out.println(Math.abs(want - 100)); + return; + } + // 3. 1개도 고장 안났을 경우 + int result = Integer.MAX_VALUE; + if(banCnt == 0) + { + result = Integer.toString(want).length(); + } + // 4. 시작하자... upper 부터 + int upper = 0; + for(upper = want; upper <= 999999;upper++) + { + String upperStr = Integer.toString(upper); + boolean flag = true; + for(int j = 0; j < upperStr.length(); j++) + { + if(ban[upperStr.charAt(j)-'0'] == true) + { + flag = false; + break; + } + } + if(flag) + { + break; + } + } + // 4-1. lower + int lower = 0; + for(lower = want; lower >= 0; lower--) + { + String lowerStr = Integer.toString(lower); + boolean flag = true; + for(int j = 0; j < lowerStr.length(); j++) + { + if(ban[lowerStr.charAt(j)-'0'] == true) + { + flag = false; + break; + } + } + if(flag) + { + break; + } + } + if(lower < 0) + { + lower = 999999; + } + int upperCnt = Math.abs(upper - want) + Integer.toString(upper).length(); + int lowerCnt = Math.abs(want - lower) + Integer.toString(lower).length(); + result = Math.min(Math.abs(want-100), Math.min(result, Math.min(upperCnt, lowerCnt))); + System.out.println(result); + } +} From c0b7d7d1d09bb316af82fa676173d0f4ede6ebd3 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sat, 15 Feb 2025 23:52:40 +0900 Subject: [PATCH 033/177] =?UTF-8?q?[15649=20N=EA=B3=BCM(1)=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15649/Main.java" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15649/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15649/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15649/Main.java" new file mode 100644 index 0000000..ac679fa --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15649/Main.java" @@ -0,0 +1,43 @@ +package BOJ15649; + +import java.util.Scanner; +import java.util.Stack; + +public class Main { + static int n; + static int m; + static boolean[] visit; + static int[] arr; + + static void dfs(int cnt) + { + if(cnt == m) + { + for(int i : arr) + { + System.out.print(i + " "); + } + System.out.println(); + return; + } + for(int i=1;i<=n;i++) + { + if(visit[i] == true) + continue; + visit[i] = true; + arr[cnt] = i; + dfs(cnt + 1); + visit[i] =false; + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + n = sc.nextInt(); + m = sc.nextInt(); + visit = new boolean[n + 1]; + arr = new int[m]; + + dfs(0); + } +} From cd249776e40ec959c0512973c29d9a799c615bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:00:31 +0900 Subject: [PATCH 034/177] =?UTF-8?q?[1476=20=EB=82=A0=EC=A7=9C=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ1476/Main.java" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1476/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1476/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1476/Main.java" new file mode 100644 index 0000000..53e64d0 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ1476/Main.java" @@ -0,0 +1,68 @@ +package BOJ1476; + +/* + * 문제 날짜 계산 +준규가 사는 나라는 우리가 사용하는 연도와 다른 방식을 이용한다. +준규가 사는 나라에서는 수 3개를 이용해서 연도를 나타낸다. +각각의 수는 지구, 태양, 그리고 달을 나타낸다. + +지구를 나타내는 수를 E, 태양을 나타내는 수를 S, 달을 나타내는 수를 M이라고 했을 때, +이 세 수는 서로 다른 범위를 가진다. (1 ≤ E ≤ 15, 1 ≤ S ≤ 28, 1 ≤ M ≤ 19) + +우리가 알고있는 1년은 준규가 살고있는 나라에서는 1 1 1로 나타낼 수 있다. +1년이 지날 때마다, 세 수는 모두 1씩 증가한다. 만약, 어떤 수가 범위를 넘어가는 경우에는 1이 된다. + +예를 들어, 15년은 15 15 15로 나타낼 수 있다. + 하지만, 1년이 지나서 16년이 되면 16 16 16이 아니라 1 16 16이 된다. 이유는 1 ≤ E ≤ 15 라서 범위를 넘어가기 때문이다. + +E, S, M이 주어졌고, 1년이 준규가 사는 나라에서 1 1 1일때, 준 +규가 사는 나라에서 E S M이 우리가 알고 있는 연도로 몇 년인지 구하는 프로그램을 작성하시오. + +입력 +첫째 줄에 세 수 E, S, M이 주어진다. 문제에 나와있는 범위를 지키는 입력만 주어진다. + +출력 +첫째 줄에 E S M으로 표시되는 가장 빠른 연도를 출력한다. 1 1 1은 항상 1이기 때문에, 정답이 음수가 나오는 경우는 없다. + +예제 입력 1 +1 16 16 +예제 출력 1 +16 +예제 입력 2 +1 1 1 +예제 출력 2 +1 +예제 입력 3 +1 2 3 +예제 출력 3 +5266 +예제 입력 4 +15 28 19 +예제 출력 4 +7980 + */ +import java.io.*; +import java.util.StringTokenizer; +public class Main { + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + int E = Integer.parseInt(st.nextToken()); + int S = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + int cnt =-1; + int s=E; + int m=E; + for(int i = E;i<=15*28*19;i+=15) { //E는 고정 +// System.out.println(i+":"+E%15+","+ s+","+m); + if ((S == s) && (M == m)) { + cnt = i; + break; + } + s = (s + 15 > 28) ? (s + 15 - 28) : (s + 15); + m = (m + 15 > 19) ? (m + 15 - 19) : (m + 15); + } + System.out.println(cnt); + } +} From eb6385a03ce4463d553dd3b6a347c563578b6bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:01:17 +0900 Subject: [PATCH 035/177] =?UTF-8?q?[2309=20=EC=9D=BC=EA=B3=B1=20=EB=82=9C?= =?UTF-8?q?=EC=9F=81=EC=9D=B4=20-=2025.02.15]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ2309/Main.java" | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ2309/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ2309/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ2309/Main.java" new file mode 100644 index 0000000..a7973dc --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ2309/Main.java" @@ -0,0 +1,72 @@ +package BOJ2309; + + +/* + * 문제 일곱 난쟁이 +왕비를 피해 일곱 난쟁이들과 함께 평화롭게 생활하고 있던 백설공주에게 위기가 찾아왔다. 일과를 마치고 돌아온 난쟁이가 일곱 명이 아닌 아홉 명이었던 것이다. + +아홉 명의 난쟁이는 모두 자신이 "백설 공주와 일곱 난쟁이"의 주인공이라고 주장했다. 뛰어난 수학적 직관력을 가지고 있던 백설공주는, 다행스럽게도 일곱 난쟁이의 키의 합이 100이 됨을 기억해 냈다. + +아홉 난쟁이의 키가 주어졌을 때, 백설공주를 도와 일곱 난쟁이를 찾는 프로그램을 작성하시오. + +입력 +아홉 개의 줄에 걸쳐 난쟁이들의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러 가지인 경우에는 아무거나 출력한다. + +출력 +일곱 난쟁이의 키를 오름차순으로 출력한다. 일곱 난쟁이를 찾을 수 없는 경우는 없다. + +예제 입력 1 +20 +7 +23 +19 +10 +15 +25 +8 +13 +예제 출력 1 +7 +8 +10 +13 +19 +20 +23 + */ +import java.io.*; +import java.util.Arrays; +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); + int [] arr = new int[9]; + int total =0; + for(int index=0;index<9;index++) { + arr[index] = Integer.parseInt(br.readLine()); + total += arr[index]; + } + Arrays.sort(arr); + int target= total -100; + int c1=-1,c2=-1; + for(int i=0;i<9;i++) { + boolean flag= false; + for(int j=i+1;j<9;j++) { + if(arr[i]+arr[j]==target) { + c1 =i; + c2 =j; + flag = true; + break; + } + } + if(flag) { + break; + } + } + + for(int i=0;i<9;i++) { + if(i!=c1 && i!=c2) { + System.out.println(arr[i]); + } + } + } +} From 71ab0da1754a070f5ac06760862945344c430774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:01:55 +0900 Subject: [PATCH 036/177] =?UTF-8?q?[3085=20=EC=82=AC=ED=83=95=20=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ3085/Main.java" | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ3085/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ3085/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ3085/Main.java" new file mode 100644 index 0000000..6d0b785 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ3085/Main.java" @@ -0,0 +1,129 @@ +package BOJ3085; + +/* + * 문제 사탕게임 +상근이는 어렸을 적에 "봄보니 (Bomboni)" 게임을 즐겨했다. + +가장 처음에 N×N크기에 사탕을 채워 놓는다. 사탕의 색은 모두 같지 않을 수도 있다. 상근이는 사탕의 색이 다른 인접한 두 칸을 고른다. 그 다음 고른 칸에 들어있는 사탕을 서로 교환한다. 이제, 모두 같은 색으로 이루어져 있는 가장 긴 연속 부분(행 또는 열)을 고른 다음 그 사탕을 모두 먹는다. + +사탕이 채워진 상태가 주어졌을 때, 상근이가 먹을 수 있는 사탕의 최대 개수를 구하는 프로그램을 작성하시오. + +입력 +첫째 줄에 보드의 크기 N이 주어진다. (3 ≤ N ≤ 50) + +다음 N개 줄에는 보드에 채워져 있는 사탕의 색상이 주어진다. 빨간색은 C, 파란색은 P, 초록색은 Z, 노란색은 Y로 주어진다. + +사탕의 색이 다른 인접한 두 칸이 존재하는 입력만 주어진다. + +출력 +첫째 줄에 상근이가 먹을 수 있는 사탕의 최대 개수를 출력한다. + +예제 입력 1 +3 +CCP +CCP +PPC +예제 출력 1 +3 +예제 입력 2 +4 +PPPP +CYZY +CCPY +PPCC +예제 출력 2 +4 +예제 입력 3 +5 +YCPZY +CYZZP +CCPPP +YCYZC +CPPZZ +예제 출력 3 +4 + */ +import java.io.*; +import java.util.Arrays; +public class Main { + static int max = 0; + static char[][] board; + static int N; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + board = new char[N][N]; + for(int i =0; i=N || nc>=N || c>=N || r>=N) { + return; + } +// for(int i =0; i=N) break; + if(board[row+i][c] == (board[row+i][c+1])) { + strike +=1; + } + else { + max = Math.max(strike, max); + strike =1; + } + max = Math.max(strike, max); + } + strike =1; + for(int r =0;r=N)break; + if(board[r][col+i] == board[r+1][col+i]) { + strike +=1; + } + else { + max = Math.max(strike, max); + strike =1; + } + max = Math.max(strike, max); + } + } + + } +} From cac22a52c916fde5cd988104b2cd0cbbb3bcdfd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:02:55 +0900 Subject: [PATCH 037/177] =?UTF-8?q?[6064=20=EC=B9=B4=EC=9E=89=EB=8B=AC?= =?UTF-8?q?=EB=A0=A5=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ6064/Main.java" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ6064/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ6064/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ6064/Main.java" new file mode 100644 index 0000000..be8c0ea --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ6064/Main.java" @@ -0,0 +1,79 @@ +package BOJ6064; + + +/* + * 문제 카잉달력 +최근에 ICPC 탐사대는 남아메리카의 잉카 제국이 놀라운 문명을 지닌 카잉 제국을 토대로 하여 세워졌다는 사실을 발견했다. + 카잉 제국의 백성들은 특이한 달력을 사용한 것으로 알려져 있다. + 그들은 M과 N보다 작거나 같은 두 개의 자연수 x, y를 가지고 각 년도를 와 같은 형식으로 표현하였다. + 그들은 이 세상의 시초에 해당하는 첫 번째 해를 <1:1>로 표현하고, + 두 번째 해를 <2:2>로 표현하였다. + 의 다음 해를 표현한 것을 이라고 하자. + 만일 x < M 이면 x' = x + 1이고, 그렇지 않으면 x' = 1이다. + 같은 방식으로 만일 y < N이면 y' = y + 1이고, 그렇지 않으면 y' = 1이다. + 은 그들 달력의 마지막 해로서, 이 해에 세상의 종말이 도래한다는 예언이 전해 온다. + +예를 들어, M = 10 이고 N = 12라고 하자. 첫 번째 해는 <1:1>로 표현되고, + 11번째 해는 <1:11>로 표현된다. <3:1>은 13번째 해를 나타내고, <10:12>는 마지막인 60번째 해를 나타낸다. + +네 개의 정수 M, N, x와 y가 주어질 때, 이 카잉 달력의 마지막 해라고 하면 는 몇 번째 해를 나타내는지 구하는 프로그램을 작성하라. + +입력 +입력 데이터는 표준 입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. + 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. + 각 테스트 데이터는 한 줄로 구성된다. 각 줄에는 네 개의 정수 M, N, x와 y가 주어진다. + (1 ≤ M, N ≤ 40,000, 1 ≤ x ≤ M, 1 ≤ y ≤ N) + 여기서 은 카잉 달력의 마지막 해를 나타낸다. + +출력 +출력은 표준 출력을 사용한다. 각 테스트 데이터에 대해, 정수 k를 한 줄에 출력한다. + 여기서 k는 가 k번째 해를 나타내는 것을 의미한다. + 만일 에 의해 표현되는 해가 없다면, 즉, 가 유효하지 않은 표현이면, -1을 출력한다. + +M=10, N=12 +<1:1> -> <2:2> -> <3:3> ... <10:10> -> <1:11> -> <2:12> -> <3:1> ... +만약 찾아야 할 x가 3이라면? 앞이 3인 것만 보면 된다. 3은? M번에 한번씩 돌아온다. +3번 13번 23번 +<3:3> -> <3:1> -> <3: > -> + ^얘는 j^ = (i+M) % N + if ((y == (i+M) %N) || (y==N && i% N ==0)) + +예제 입력 1 +3 +10 12 3 9 +10 12 7 2 +13 11 5 6 + + +예제 출력 1 +33 +-1 +83 + */ +import java.io.*; +import java.util.StringTokenizer; +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int T = Integer.parseInt(br.readLine()); + + for(int test_case =1; test_case<=T; test_case++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int M = Integer.parseInt(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + int x = Integer.parseInt(st.nextToken()); + int y = Integer.parseInt(st.nextToken()); + int ans =-1; + for (int i=x; i<=M*N;i+=M) { +// System.out.printf("%d번째 : <%d:%d>\n",i,x,(i+M)%N); + if ( (y==N && i% N ==0) || (i%N)==y ) { + ans = i; + break; + } + } + System.out.printf("%d\n",ans); + } + + } +} From e8b03769886ecbb44dd78103282b6423416c5984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:03:31 +0900 Subject: [PATCH 038/177] =?UTF-8?q?[15651=20N=EA=B3=BC=20M=20(1)=20-=2025-?= =?UTF-8?q?02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15651/Main.java" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15651/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15651/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15651/Main.java" new file mode 100644 index 0000000..919d695 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15651/Main.java" @@ -0,0 +1,63 @@ +package BOJ15651; + + + + +/* + * 문제 N 과 M (3) +자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. + +1부터 N까지 자연수 중에서 M개를 고른 수열 +같은 수를 여러 번 골라도 된다. +입력 +첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 7) + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +예제 출력 1 +1 +2 +3 + */ + + +import java.io.*; +import java.util.StringTokenizer;; +public class Main { + static int N,M; + static int[] ans; + static BufferedWriter bw; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + ans = new int[M]; + + dfs(0); + bw.flush(); + } + + + static void dfs(int depth) throws Exception { + if(depth==M) { + for(int i:ans) { + bw.write(i+" "); + } + bw.write("\n"); + return; + } + else { + for(int i=1;i<=N;i++) { + ans[depth]=i; + dfs(depth+1); + } + } + } +} From 641f8009bb50f77009295fb7ac7552609a74b46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:04:28 +0900 Subject: [PATCH 039/177] =?UTF-8?q?[15652=20N=EA=B3=BC=20M=20(4)=20-=2025-?= =?UTF-8?q?02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15652/Main.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15652/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15652/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15652/Main.java" new file mode 100644 index 0000000..baae4b7 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15652/Main.java" @@ -0,0 +1,64 @@ +package BOJ15652; + +/*문제 N과 M (4) +자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. + +1부터 N까지 자연수 중에서 M개를 고른 수열 +같은 수를 여러 번 골라도 된다. +고른 수열은 비내림차순이어야 한다. +길이가 K인 수열 A가 A1 ≤ A2 ≤ ... ≤ AK-1 ≤ AK를 만족하면, 비내림차순이라고 한다. + +입력 +첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +예제 출력 1 +1 +2 +3 + * + * + */ + +import java.io.*; +import java.util.StringTokenizer; +public class Main { + static int N,M; + static BufferedWriter bw; + static int[] ans; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + ans = new int[M]; + + dfs(0,1); + + bw.flush(); + } + + static void dfs(int depth,int start) throws IOException { + if(depth == M) { + for(int i: ans) { + bw.write(i+" "); + } + bw.write("\n"); + return; + } + else { + for(int i = start; i<=N;i++) { + ans[depth] = i; + dfs(depth+1,i); + } + } + } + +} From 48ddf49c0c070d9b06abc5d43287588cb0fff62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 16 Feb 2025 00:05:12 +0900 Subject: [PATCH 040/177] =?UTF-8?q?[15654=20N=EA=B3=BC=20M=20(5)=20-=2025-?= =?UTF-8?q?02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15654/Main.java" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15654/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15654/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15654/Main.java" new file mode 100644 index 0000000..76f1505 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15654/Main.java" @@ -0,0 +1,79 @@ +package BOJ15654; + + + +/* + * 문제 N과 M (5) +N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. + +N개의 자연수 중에서 M개를 고른 수열 + +입력 +첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) + +둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +4 5 2 +예제 출력 1 +2 +4 +5 + */ +import java.util.Arrays; +import java.util.StringTokenizer; +import java.io.*; +public class Main { + static int[] arr,ans; + static int M,N; + static boolean[] visited; + static BufferedWriter bw; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + arr = new int[N]; + ans = new int[M]; + visited = new boolean[N]; + st = new StringTokenizer(br.readLine()); + for(int i = 0; i< N;i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + dfs(0); + bw.flush(); + } + + + static void dfs(int depth) throws IOException { + if(depth==M) { + for(int i : ans) { +// System.out.print(i+" "); + bw.write(i+" "); + } +// System.out.println(); + bw.write("\n"); + return; + } + + else { + for(int i = 0; i Date: Sun, 16 Feb 2025 00:05:43 +0900 Subject: [PATCH 041/177] =?UTF-8?q?[15655=20N=EA=B3=BC=20M=20(6)=20-=2025-?= =?UTF-8?q?02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15655/Main.java" | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15655/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15655/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15655/Main.java" new file mode 100644 index 0000000..1626679 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15655/Main.java" @@ -0,0 +1,91 @@ +package BOJ15655; + + +/* + * 문제 N과 M (6) +N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. + +N개의 자연수 중에서 M개를 고른 수열 +고른 수열은 오름차순이어야 한다. + +입력 +첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) + +둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +4 5 2 +예제 출력 1 +2 +4 +5 +예제 입력 2 +4 2 +9 8 7 1 +예제 출력 2 +1 7 +1 8 +1 9 +7 8 +7 9 +8 9 +예제 입력 3 +4 4 +1231 1232 1233 1234 +예제 출력 3 +1231 1232 1233 1234 + */ +import java.util.StringTokenizer; +import java.io.*; +import java.util.Arrays; +public class Main { + static int N,M; + static int[] arr; + static int[] ans; + static boolean[] visited; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + arr = new int [N]; + ans = new int [M]; + visited = new boolean[N]; + st = new StringTokenizer(br.readLine()); + for( int i = 0; i< N ; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + dfs(0,0); + } + + static void dfs(int depth, int start) { + if (depth == M) { + for(int i : ans) { + System.out.print(i+" "); + } + System.out.println(); + return; + } + else { + for(int i = start; i Date: Sun, 16 Feb 2025 00:06:05 +0900 Subject: [PATCH 042/177] =?UTF-8?q?[15656=20N=EA=B3=BC=20M=20(7)=20-=2025-?= =?UTF-8?q?02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15656/Main.java" | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15656/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15656/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15656/Main.java" new file mode 100644 index 0000000..6921677 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15656/Main.java" @@ -0,0 +1,123 @@ +package BOJ15656; + + +/* + * 문제 N과 M (7) +N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. + +N개의 자연수 중에서 M개를 고른 수열 +같은 수를 여러 번 골라도 된다. +입력 +첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 7) + +둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. +*/ +import java.util.Arrays; +import java.util.StringTokenizer; +import java.io.*; +public class Main { + static int[] arr; + static int[] ans; + static int N,M; + static BufferedWriter bw; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + arr = new int[N]; + ans = new int[M]; + + st = new StringTokenizer(br.readLine()); + for (int i =0; i Date: Sun, 16 Feb 2025 00:06:53 +0900 Subject: [PATCH 043/177] =?UTF-8?q?[15657=20N=EA=B3=BC=20M=20(8)=20-=2025-?= =?UTF-8?q?02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ15657/Main.java" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15657/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15657/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15657/Main.java" new file mode 100644 index 0000000..950b0ec --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ15657/Main.java" @@ -0,0 +1,69 @@ +package BOJ15657; + +/* + * 문제 N과 M (8) +N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. + +N개의 자연수 중에서 M개를 고른 수열 +같은 수를 여러 번 골라도 된다. +고른 수열은 비내림차순이어야 한다. +길이가 K인 수열 A가 A1 ≤ A2 ≤ ... ≤ AK-1 ≤ AK를 만족하면, 비내림차순이라고 한다. +입력 +첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) + +둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. + +출력 +한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +예제 입력 1 +3 1 +4 5 2 +예제 출력 1 +2 +4 +5 + */ + +import java.io.*; +import java.util.Arrays; +import java.util.StringTokenizer; +public class Main { + static BufferedWriter bw; + static int N,M; + static int[] ans,arr; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + arr = new int[N]; + ans = new int[M]; + st = new StringTokenizer(br.readLine()); + for(int i = 0 ; i< N ; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + dfs(0,0); + + bw.flush(); + } + static void dfs(int depth,int start) throws Exception{ + if(depth==M) { + for(int i : ans) { + bw.write(i+" "); + } + bw.write("\n"); + return; + } + else { + for(int i = start;i Date: Sun, 16 Feb 2025 00:07:28 +0900 Subject: [PATCH 044/177] =?UTF-8?q?[18290=20NM=EA=B3=BC=20K=20(1)=20-=2025?= =?UTF-8?q?-02-16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ18290/Main.java" | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ18290/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ18290/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ18290/Main.java" new file mode 100644 index 0000000..edc6013 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ18290/Main.java" @@ -0,0 +1,101 @@ +package BOJ18290; + + +/*문제 18290 +크기가 N×M인 격자판의 각 칸에 정수가 하나씩 들어있다. 이 격자판에서 칸 K개를 선택할 것이고, 선택한 칸에 들어있는 수를 모두 더한 값의 최댓값을 구하려고 한다. 단, 선택한 두 칸이 인접하면 안된다. r행 c열에 있는 칸을 (r, c)라고 했을 때, (r-1, c), (r+1, c), (r, c-1), (r, c+1)에 있는 칸이 인접한 칸이다. + +입력 +첫째 줄에 N, M, K가 주어진다. 둘째 줄부터 N개의 줄에 격자판에 들어있는 수가 주어진다. + +출력 +선택한 칸에 들어있는 수를 모두 더한 값의 최댓값을 출력한다. + +제한 +1 ≤ N, M ≤ 10 +1 ≤ K ≤ min(4, N×M) +격자판에 들어있는 수는 -10,000보다 크거나 같고, 10,000보다 작거나 같은 정수이다. +항상 K개의 칸을 선택할 수 있는 경우만 입력으로 주어진다. +예제 입력 1 +1 1 1 +1 +예제 출력 1 +1 + * + */ +import java.io.*; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int N, M, K; + static int[][] arr; + static boolean[][] visited; + static BufferedWriter bw; + static int max = Integer.MIN_VALUE; + static int[] dr = {-1, 1, 0, 0}; // 상하좌우 + static int[] dc = {0, 0, -1, 1}; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + K = Integer.parseInt(st.nextToken()); + arr = new int[N][M]; + visited = new boolean[N][M]; + + for (int row = 0; row < N; row++) { + st = new StringTokenizer(br.readLine()); + for (int col = 0; col < M; col++) { + arr[row][col] = Integer.parseInt(st.nextToken()); + } + } + + dfs(0, 0); + bw.write(max + "\n"); + bw.flush(); + } + + static void dfs(int depth, int total) throws Exception { + if (depth == K) { + max = Math.max(total, max); + return; + } + + // (r, c)에서 선택할 칸을 찾기 + for (int row = 0; row < N; row++) { + for (int col = 0; col < M; col++) { + if (!visited[row][col]) { + // 방문 처리 + visited[row][col] = true; + // 인접한 칸들 방문 처리 + boolean[] tempVisited = new boolean[4]; // 4방향 방문 처리 + for (int d = 0; d < 4; d++) { + int nr = row + dr[d]; + int nc = col + dc[d]; + if (nr >= 0 && nr < N && nc >= 0 && nc < M) { + tempVisited[d] = visited[nr][nc]; + visited[nr][nc] = true; + } + } + + // 재귀 호출 + dfs(depth + 1, total + arr[row][col]); + + // 인접한 칸들 복원 처리 + for (int d = 0; d < 4; d++) { + int nr = row + dr[d]; + int nc = col + dc[d]; + if (nr >= 0 && nr < N && nc >= 0 && nc < M) { + visited[nr][nc] = tempVisited[d]; + } + } + + // 현재 칸 복원 + visited[row][col] = false; + } + } + } + } +} From 33475112f10e593247122e6de31f2c012388c509 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 03:04:14 +0900 Subject: [PATCH 045/177] =?UTF-8?q?[14500=20=ED=85=8C=ED=8A=B8=EB=A1=9C?= =?UTF-8?q?=EB=AF=B8=EB=85=B8=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_14500/Main.java" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_14500/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_14500/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_14500/Main.java" new file mode 100644 index 0000000..11da0a0 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_14500/Main.java" @@ -0,0 +1,71 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int[][] arr; + static int N,M; + static int Max = 0; + static boolean[][] visited; + static int[] dx = {-1, 0 ,1,0}; + static int[] dy = {0,1,0,-1}; + + + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st=new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + arr= new int[N][M]; + visited = new boolean[N][M]; + + for(int i = 0; i=N || nx<0 ||ny>=M || ny<0) continue; + + if(!visited[nx][ny]) { + if(num==2) { + visited[nx][ny] = true; + sol(num+1, now_sum+arr[nx][ny], x,y); + visited[nx][ny] = false; + } + visited[nx][ny] = true; + sol(num+1, now_sum+arr[nx][ny], nx,ny); + visited[nx][ny] = false; + + } + } + } +} From 8173f5d1da75efffdf6145a1f96b3de4cb46fbca Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 15:43:38 +0900 Subject: [PATCH 046/177] =?UTF-8?q?[14500=20=ED=85=8C=ED=8A=B8=EB=A1=9C?= =?UTF-8?q?=EB=AF=B8=EB=85=B8=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ14500/Main.java" | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ14500/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ14500/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ14500/Main.java" new file mode 100644 index 0000000..e4dc677 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ14500/Main.java" @@ -0,0 +1,95 @@ +package BOJ14500; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int result = 0; + static int[] dr = {1,-1 ,0, 0}; + static int[] dc = {0,0,1,-1}; + static int n; + static int m; + + static int[][] map; + static boolean[][] visit; + + static void dfs(int cnt,int sum, int nowR, int nowC){ + if(cnt == 4) + { + result = Math.max(result, sum); + return; + } + for(int i = 0;i<4;i++) + { + int nextR = nowR + dr[i]; + int nextC = nowC + dc[i]; + // 범위 처리 + if(nextR < 0 || nextC < 0 || nextR >= n || nextC >= m) + continue; + // 방문 처리 + if(visit[nextR][nextC]) + continue; + visit[nextR][nextC] = true; + dfs(cnt+1,sum + map[nextR][nextC],nextR,nextC); + visit[nextR][nextC] = false; + } + } + + static void specialCase(int nowR, int nowC){ + // ㅗ + if(nowR-1>=0 && nowC-1>=0 && nowC+1=0 && nowC+1=0 && nowC-1>=0 && nowR + 1=0 && nowC+1< m && nowR + 1 Date: Sun, 16 Feb 2025 16:38:47 +0900 Subject: [PATCH 047/177] =?UTF-8?q?[6064=20=EC=B9=B4=EC=9E=89=EB=8B=AC?= =?UTF-8?q?=EB=A0=A5=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ6064/Main.java" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ6064/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ6064/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ6064/Main.java" new file mode 100644 index 0000000..1b9b83e --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ6064/Main.java" @@ -0,0 +1,53 @@ +package BOJ6064; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.Buffer; +import java.util.StringTokenizer; + +public class Main { + + static int gcd(int n1, int n2) + { + if(n1 > n2) + { + int tmp = n1; + n1 = n2; + n2 = tmp; + } + while(n2 % n1 != 0) // 안 나눠질 동안 + { + int tmp = n2 % n1; + n2 = n1; + n1 = tmp; + } + return n1; + } + + static int lcm(int n1, int n2){ + return n1*n2 / gcd(n1, n2); + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + int testCase = Integer.parseInt(br.readLine()); + for(int t = 0; t < testCase; t++) { + st = new StringTokenizer(br.readLine()); + int m = Integer.parseInt(st.nextToken()); + int n = Integer.parseInt(st.nextToken()); + int x= Integer.parseInt(st.nextToken()); + int y = Integer.parseInt(st.nextToken()); + int result = -1; + int limit = m * n; + for(int i = x; i < limit + 1; i=i+m) { + if((i-y)%n == 0){ + result = i; + break; + } + } + System.out.println(result); + } + } +} From 7b8e458ae8f2c1ac84c3ba9485b83bbc22cebfa9 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Wed, 12 Feb 2025 23:53:31 +0900 Subject: [PATCH 048/177] =?UTF-8?q?[1476=20=EB=82=A0=EC=A7=9C=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20-=2025.02.12]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\247\234\352\263\204\354\202\260.java" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1476_\353\202\240\354\247\234\352\263\204\354\202\260.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1476_\353\202\240\354\247\234\352\263\204\354\202\260.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1476_\353\202\240\354\247\234\352\263\204\354\202\260.java" new file mode 100644 index 0000000..9eba850 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1476_\353\202\240\354\247\234\352\263\204\354\202\260.java" @@ -0,0 +1,30 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_1476_날짜계산 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int targetE = Integer.parseInt(st.nextToken()); + int targetS = Integer.parseInt(st.nextToken()); + int targetM = Integer.parseInt(st.nextToken()); + + int year = 1, currentE = 1, currentS = 1, currentM = 1; + + while (true) { + if (currentE == targetE && currentS == targetS && currentM == targetM) { + System.out.println(year); + break; + } + + currentE = ++currentE > 15 ? 1 : currentE; + currentS = ++currentS > 28 ? 1 : currentS; + currentM = ++currentM > 19 ? 1 : currentM; + year++; + + } + } +} From b08c534bd1491801561d0c98c33ed0af95bf45fc Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 16:43:55 +0900 Subject: [PATCH 049/177] =?UTF-8?q?[1107=20=EB=A6=AC=EB=AA=A8=EC=BB=A8=20-?= =?UTF-8?q?=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\246\254\353\252\250\354\273\250.java" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1107_\353\246\254\353\252\250\354\273\250.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1107_\353\246\254\353\252\250\354\273\250.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1107_\353\246\254\353\252\250\354\273\250.java" new file mode 100644 index 0000000..6097f72 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1107_\353\246\254\353\252\250\354\273\250.java" @@ -0,0 +1,59 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.StringTokenizer; + +//백준 1107번 +public class BOJ_1107_리모컨 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int targetNum = Integer.parseInt(br.readLine()); + int brokenBtsCount = Integer.parseInt(br.readLine()); + HashSet brokenBtnSet = new HashSet<>(); + // 고장난 버튼이 있는 경우만 입력받음. + if (brokenBtsCount != 0) { + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < brokenBtsCount; idx++) { + brokenBtnSet.add(Integer.parseInt(st.nextToken())); + } + } + + int minPushCount = Integer.MAX_VALUE; + + // 1. 이동하려고 하는 채널이 100인 경우 -> 0 출력 후 종료한다. + if (targetNum == 100) { + System.out.println(0); + return; + } + + // 2. 100에서 +/- 버튼만 눌러서 이동하는 경우 + minPushCount = Math.min(minPushCount, Math.abs(targetNum - 100)); + + // 3. 번호를 누르는 경우 -> 0~999,999까지 가능한 경우를 다 해본다. + HashSet availableNumBtnSet = new HashSet<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); + availableNumBtnSet.removeAll(brokenBtnSet); + + for (int closestNum = 0; closestNum <= 999_999; closestNum++) { + // 누를 수 있는 숫자인지 확인함 + String closestNumStr = Integer.toString(closestNum); + boolean flag = true; + for (int i = 0; i < closestNumStr.length(); i++) { + // 고장난 버튼 숫자가 포함되어 있으면 + if (!availableNumBtnSet.contains(closestNumStr.charAt(i) - '0')) { + flag = false; + break; + } + } + // 누를 수 있는 숫자면 -> (숫자 누르는 횟수 + -/+ 누르는 횟수 계산 해서 minPush값이랑 비교함) + if (flag == true) { + minPushCount = Math.min(minPushCount, closestNumStr.length() + Math.abs(targetNum - closestNum)); + } + } + + System.out.println(minPushCount); + + } + +} \ No newline at end of file From b6a9a1631d7ef12bc4af1e208a76bb08b68435e0 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 17:33:07 +0900 Subject: [PATCH 050/177] =?UTF-8?q?[1748=20=EC=88=98=20=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=20=EC=93=B0=EA=B8=B0=201=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ1748/Main.java" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1748/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1748/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1748/Main.java" new file mode 100644 index 0000000..b1232e6 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ1748/Main.java" @@ -0,0 +1,23 @@ +package BOJ1748; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long n = sc.nextInt(); + long result = 0; + long digit = 1; // 자리수 (1, 10, 100, 1000, ...) + int length = 1; // 현재 자리수의 길이 + + while(digit * 10 <= n) + { + result = result + (length * 9 * digit); + length++; + digit = digit * 10; + } + + result = result + (n - digit + 1) * length; + System.out.println(result); + } +} + From 8da50acf071016d592a0c3084b6ef8adc2e79c4c Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 17:43:50 +0900 Subject: [PATCH 051/177] =?UTF-8?q?[9095=20123=20=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ9095/Main.java" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ9095/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ9095/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ9095/Main.java" new file mode 100644 index 0000000..0e39f45 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ9095/Main.java" @@ -0,0 +1,26 @@ +package BOJ9095; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + int testCase = Integer.parseInt(br.readLine()); + int[] dp = new int[11]; + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i=4; i <= 10;i++){ + dp[i] = dp[i-3] + dp[i-2] + dp[i-1]; + } + + for(int t = 1; t <= testCase; t++) { + int n = Integer.parseInt(br.readLine()); + System.out.println(dp[n]); + } + } +} From e55e831989dea2bb70f6540afc8094ddea5ad0e8 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 17:55:50 +0900 Subject: [PATCH 052/177] =?UTF-8?q?[15650=20N=EA=B3=BCM(2)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15650/Main.java" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15650/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15650/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15650/Main.java" new file mode 100644 index 0000000..67bbeff --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15650/Main.java" @@ -0,0 +1,41 @@ +package BOJ15650; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + + static int[] result; + + static void dfs(int n, int m, int cnt, int now){ + if(cnt == m) + { + for(int i : result) + { + System.out.print(i + " "); + } + System.out.println(); + return; + } + for(int i = now + 1; i <= n; i++) + { + result[cnt] = i; + dfs(n, m, cnt + 1, i); + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + st = new StringTokenizer(br.readLine()); + int n = Integer.parseInt(st.nextToken()); + int m = Integer.parseInt(st.nextToken()); + result = new int[m]; + for(int i = 1; i <= n; i++){ + result[0] = i; + dfs(n,m,1, i); + } + } +} From 1d6368ab324473f11e46430e4aaaa50bdab1b78a Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 18:49:56 +0900 Subject: [PATCH 053/177] =?UTF-8?q?[15652=20N=EA=B3=BCM(4)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15651/Main.java" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15651/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15651/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15651/Main.java" new file mode 100644 index 0000000..4e17ff4 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15651/Main.java" @@ -0,0 +1,41 @@ +package BOJ15651; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +// 한번에 출력 해보기 + +public class Main { + static int[] result; + static StringBuilder sb = new StringBuilder(); + static void dfs(int n, int m, int cnt){ + if(cnt == m) + { + for(int i : result) + { + sb.append(i).append(" "); + } + sb.append("\n"); + return; + } + for(int i = 1; i <= n; i++) + { + result[cnt] = i; + dfs(n, m, cnt + 1); + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + st = new StringTokenizer(br.readLine()); + int n = Integer.parseInt(st.nextToken()); + int m = Integer.parseInt(st.nextToken()); + result = new int[m]; + dfs(n, m, 0); + + System.out.println(sb.toString()); + } +} From 08ee413063559b127d8feed139659e96c4111366 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 19:00:08 +0900 Subject: [PATCH 054/177] =?UTF-8?q?[14652=20N=EA=B3=BCM(4)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15652/Main.java" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15652/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15652/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15652/Main.java" new file mode 100644 index 0000000..fb3b23a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15652/Main.java" @@ -0,0 +1,51 @@ +package BOJ15652; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +// 한번에 출력 해보기 + +public class Main { + static int[] result; + static StringBuilder sb = new StringBuilder(); + static void dfs(int n, int m, int cnt){ + if(cnt == m) + { + for(int i : result) + { + sb.append(i).append(" "); + } + sb.append("\n"); + return; + } + for(int i = 1; i <= n; i++) + { + if(cnt == 0) + { + result[cnt] = i; + } + else{ + if(result[cnt-1] > i) + continue; + else{ + result[cnt] = i; + } + } + dfs(n, m, cnt + 1); + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + st = new StringTokenizer(br.readLine()); + int n = Integer.parseInt(st.nextToken()); + int m = Integer.parseInt(st.nextToken()); + result = new int[m]; + dfs(n,m,0); + + System.out.println(sb.toString()); + } +} From 6d3ca2ced37441df32a147b5196ddbcca96edc48 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 19:17:47 +0900 Subject: [PATCH 055/177] =?UTF-8?q?[6064=20=EC=B9=B4=EC=9E=89=20=EB=8B=AC?= =?UTF-8?q?=EB=A0=A5=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_6064/Main.java" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_6064/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_6064/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_6064/Main.java" new file mode 100644 index 0000000..e6942a4 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_6064/Main.java" @@ -0,0 +1,36 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int T = Integer.parseInt(br.readLine()); + for(int t = 0;t Date: Sun, 16 Feb 2025 19:36:31 +0900 Subject: [PATCH 056/177] =?UTF-8?q?[1748=20=EC=88=98=20=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=20=EC=93=B0=EA=B8=B01=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_1748/Main.java" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1748/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1748/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1748/Main.java" new file mode 100644 index 0000000..b696220 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_1748/Main.java" @@ -0,0 +1,25 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String str = br.readLine(); + int num = Integer.parseInt(str); + int sum=0; + + for(int i =str.length();i>1;i--) { + + int a = num-((int)Math.pow(10,i-1)-1); + num-=a; + sum+= a*i; + } + + sum+=num; + + System.out.println(sum); + } +} From 83a4a62cb4300b41229b837fc086e2c1b12bb750 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 19:38:51 +0900 Subject: [PATCH 057/177] =?UTF-8?q?[15654=20N=EA=B3=BCM(5)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15654/Main.java" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15654/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15654/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15654/Main.java" new file mode 100644 index 0000000..07a8ab2 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15654/Main.java" @@ -0,0 +1,59 @@ +package BOJ15654; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.StringTokenizer; + +public class Main { + static StringBuilder sb = new StringBuilder(); + static int n; + static int m; + static int[] arr; + static int[] result; + static boolean[] visit; + static void dfs(int n, int m, int cnt){ + if(cnt == m) + { + for(int i : result){ + sb.append(i).append(" "); + } + sb.append("\n"); + return; + } + + for(int i = 0 ; i < n ; i++){ + if(visit[i]) + continue; + visit[i] = true; + result[cnt] = arr[i]; + dfs(n,m,cnt+1); + visit[i] = false; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + // 입력 + st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + arr = new int[n]; + result = new int[m]; + visit = new boolean[n]; + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < n; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + + dfs(n,m,0); + System.out.println(sb.toString()); + } +} From 21dd1ed650586e082d4c6b24379e22138e6332b5 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 19:44:27 +0900 Subject: [PATCH 058/177] =?UTF-8?q?[15655=20N=EA=B3=BCM(6)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15655/Main.java" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15655/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15655/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15655/Main.java" new file mode 100644 index 0000000..0ac9f8a --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15655/Main.java" @@ -0,0 +1,63 @@ +package BOJ15655; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.StringTokenizer; + +public class Main { + static StringBuilder sb = new StringBuilder(); + static int n; + static int m; + static int[] arr; + static int[] result; + static boolean[] visit; + static void dfs(int n, int m, int cnt, int now){ + if(cnt == m) + { + for(int i : result){ + sb.append(i).append(" "); + } + sb.append("\n"); + return; + } + + for(int i = now + 1 ; i < n ; i++){ + if(visit[i]) + continue; + visit[i] = true; + result[cnt] = arr[i]; + dfs(n,m,cnt+1, i); + visit[i] = false; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + // 입력 + st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + arr = new int[n]; + result = new int[m]; + visit = new boolean[n]; + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < n; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + + for(int i = 0; i < n;i++) + { + result[0] = arr[i]; + dfs(n,m,1, i); + } + System.out.println(sb.toString()); + } +} From 093ba738ff2577a455f9ccdbe77993fa46696e25 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 19:48:19 +0900 Subject: [PATCH 059/177] =?UTF-8?q?[15656=20N=EA=B3=BCM(7)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15656/Main.java" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15656/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15656/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15656/Main.java" new file mode 100644 index 0000000..328cf5f --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15656/Main.java" @@ -0,0 +1,63 @@ +package BOJ15656; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.StringTokenizer; + +public class Main { + static StringBuilder sb = new StringBuilder(); + static int n; + static int m; + static int[] arr; + static int[] result; + static boolean[] visit; + static void dfs(int n, int m, int cnt, int now){ + if(cnt == m) + { + for(int i : result){ + sb.append(i).append(" "); + } + sb.append("\n"); + return; + } + + for(int i = 0 ; i < n ; i++){ +// if(visit[i]) +// continue; + visit[i] = true; + result[cnt] = arr[i]; + dfs(n,m,cnt+1, i); + visit[i] = false; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + // 입력 + st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + arr = new int[n]; + result = new int[m]; + visit = new boolean[n]; + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < n; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + + for(int i = 0; i < n;i++) + { + result[0] = arr[i]; + dfs(n,m,1, i); + } + System.out.println(sb.toString()); + } +} From dab16573c86bd9d27bb2c984e640dada53dd2e29 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 19:50:48 +0900 Subject: [PATCH 060/177] =?UTF-8?q?[15657=20N=EA=B3=BCM(8)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ15657/Main.java" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15657/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15657/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15657/Main.java" new file mode 100644 index 0000000..666e44e --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ15657/Main.java" @@ -0,0 +1,63 @@ +package BOJ15657; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.StringTokenizer; + +public class Main { + static StringBuilder sb = new StringBuilder(); + static int n; + static int m; + static int[] arr; + static int[] result; + static boolean[] visit; + static void dfs(int n, int m, int cnt, int now){ + if(cnt == m) + { + for(int i : result){ + sb.append(i).append(" "); + } + sb.append("\n"); + return; + } + + for(int i = now ; i < n ; i++){ +// if(visit[i]) +// continue; + visit[i] = true; + result[cnt] = arr[i]; + dfs(n,m,cnt+1, i); + visit[i] = false; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + // 입력 + st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + arr = new int[n]; + result = new int[m]; + visit = new boolean[n]; + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < n; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + Arrays.sort(arr); + + for(int i = 0; i < n;i++) + { + result[0] = arr[i]; + dfs(n,m,1, i); + } + System.out.println(sb.toString()); + } +} From cb7d286ba2d4961c42ed2efbbcc6cdc125931904 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 19:55:14 +0900 Subject: [PATCH 061/177] =?UTF-8?q?[9095=201,2,3=20=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_9095/Main.java" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_9095/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_9095/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_9095/Main.java" new file mode 100644 index 0000000..b580598 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_9095/Main.java" @@ -0,0 +1,29 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine()); + + int[] dp = new int[11]; + + dp[1] =1; + dp[2] =2; + dp[3] =4; + + for(int i =4;i<11;i++) { + dp[i] = dp[i-1]+dp[i-2] +dp[i-3]; + } + + for(int i=0;i Date: Sun, 16 Feb 2025 20:13:53 +0900 Subject: [PATCH 062/177] =?UTF-8?q?[15649=20N=EA=B3=BC=20M(1)=20-=2025.02.?= =?UTF-8?q?16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15649/Main.java" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15649/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15649/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15649/Main.java" new file mode 100644 index 0000000..a4d50df --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15649/Main.java" @@ -0,0 +1,47 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + static boolean[] visited; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + visited = new boolean[N+1]; + arr= new int[M]; + + nm(N,M, 0); + + } + + public static void nm(int n, int m, int now) { + if(m==now) { + for(int a :arr) { + System.out.print(a+" "); + } + System.out.println(); + return; + } + + for(int i=1;i<=n;i++) { + if(!visited[i]) { + visited[i] =true; + arr[now] = i; + nm(n,m,now+1); + visited[i] =false; + } + } + + return; + } + +} From ee4b5332f0ebd262042aee265c8f38cbeff2915e Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 20:26:04 +0900 Subject: [PATCH 063/177] =?UTF-8?q?[15650=20N=EA=B3=BC=20M=20(2)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15650/Main.java" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15650/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15650/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15650/Main.java" new file mode 100644 index 0000000..48e330b --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15650/Main.java" @@ -0,0 +1,53 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + //static boolean[] visited; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + //visited = new boolean[N+1]; + arr= new int[M]; + + nm(N,M, 0,1); + + } + + public static void nm(int n, int m, int now, int start) { + if(m==now) { + for(int a :arr) { + System.out.print(a+" "); + } + System.out.println(); + return; + } + + for(int i=start;i<=n;i++) { + /* + if(!visited[i]) { + visited[i] =true; + arr[now] = i; + nm(n,m,now+1); + visited[i] =false; + } + */ + + arr[now] = i; + nm(n,m,now+1,i+1); + } + + return; + } + +} From 216db50159501d83898b21d9e6b5901267eaa734 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 20:36:12 +0900 Subject: [PATCH 064/177] =?UTF-8?q?[15651=20N=EA=B3=BC=20M=20(3)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15651/Main.java" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15651/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15651/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15651/Main.java" new file mode 100644 index 0000000..97e0a3b --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15651/Main.java" @@ -0,0 +1,56 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + //static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + //visited = new boolean[N+1]; + arr= new int[M]; + + nm(N,M, 0); + + System.out.println(sb); + + } + + public static void nm(int n, int m, int now) { + if(m==now) { + for(int a :arr) { + sb.append(a+" "); + } + sb.append("\n"); + return; + } + + for(int i=1;i<=n;i++) { + /* + if(!visited[i]) { + visited[i] =true; + arr[now] = i; + nm(n,m,now+1); + visited[i] =false; + } + */ + + arr[now] = i; + nm(n,m,now+1); + } + + return; + } + +} From dbd08ad3427b740908abebdb83932329dd49847e Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 16 Feb 2025 20:39:20 +0900 Subject: [PATCH 065/177] =?UTF-8?q?[18290=20NM=EA=B3=BCK(1)=20-=2025.02.16?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chulhyeonn/src/BOJ18290/Main.java" | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ18290/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ18290/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ18290/Main.java" new file mode 100644 index 0000000..d624715 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/chulhyeonn/src/BOJ18290/Main.java" @@ -0,0 +1,72 @@ +package BOJ18290; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +class Main { + static int n; + static int m; + static int k; + static int[][] map; + static boolean[][] visit; + static int[] dr = {1,-1,0,0}; + static int[] dc = {0,0,1,-1}; + static int result = Integer.MIN_VALUE; + static void dfs(int cnt, int sum){ + if(k == cnt) + { + result = Math.max(result, sum); + return; + } + for(int nowR = 0; nowR = 0 && nextC >= 0 && nextR < n && nextC < m && visit[nextR][nextC]) // next가 범위 안에 있고 + { + canGo = false; + break; + } + } + // canGo 가 true라면 dfs진행 + if(canGo == false) + { + continue; + } + visit[nowR][nowC] = true; + dfs(cnt+1, sum+map[nowR][nowC]); + visit[nowR][nowC] = false; + } + } + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + k = Integer.parseInt(st.nextToken()); + map = new int[n][m]; + visit = new boolean[n][m]; + // 맵 입력 + for(int i = 0; i < n; i++){ + String row = br.readLine(); + st = new StringTokenizer(row); + for(int j = 0; j < m; j++){ + map[i][j] = Integer.parseInt(st.nextToken()); + } + } + // dfs + dfs(0, 0); + System.out.println(result); + } +} From ee16de97a43264fccd09db765c639f653568a376 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 20:45:52 +0900 Subject: [PATCH 066/177] =?UTF-8?q?[15652=20N=EA=B3=BC=20M=20(4)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15652/Main.java" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15652/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15652/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15652/Main.java" new file mode 100644 index 0000000..80f9025 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15652/Main.java" @@ -0,0 +1,56 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + //static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + //visited = new boolean[N+1]; + arr= new int[M]; + + nm(N,M, 0,1); + + System.out.println(sb); + + } + + public static void nm(int n, int m, int now,int start) { + if(m==now) { + for(int a :arr) { + sb.append(a+" "); + } + sb.append("\n"); + return; + } + + for(int i=start;i<=n;i++) { + /* + if(!visited[i]) { + visited[i] =true; + arr[now] = i; + nm(n,m,now+1); + visited[i] =false; + } + */ + + arr[now] = i; + nm(n,m,now+1,i); + } + + return; + } + +} From 342128be42db8efb308d247ce577cf46cd869f55 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:48:35 +0900 Subject: [PATCH 067/177] =?UTF-8?q?[15649=20N=EA=B3=BCM(1)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15649_N\352\263\274M_1.java" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15649_N\352\263\274M_1.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15649_N\352\263\274M_1.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15649_N\352\263\274M_1.java" new file mode 100644 index 0000000..8b1ecc4 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15649_N\352\263\274M_1.java" @@ -0,0 +1,55 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/** + * N개의 값 중에서 M개의 숫자를 순서를 고려해서 뽑는 경우를 구하는 순열 문제이다. + */ +public class BOJ_15649_N과M_1 { + + static int N; + static int M; + static int[] pArr; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + pArr = new int[M]; + visited = new boolean[N + 1]; + + backtrack(0); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == M) { + for (int i = 0; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + for (int num = 1; num <= N; num++) { + // 방문하지 않은 숫자면 + if (visited[num] == false) { + visited[num] = true; + pArr[length] = num; // 배열에 숫자 추가 + backtrack(length + 1); + visited[num] = false; + + } + } + + } + +} From b32f54f54646a9f33b2f0c514836751494c78121 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:48:59 +0900 Subject: [PATCH 068/177] =?UTF-8?q?[15650=20N=EA=B3=BCM(2)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15650_N\352\263\274M_2.java" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15650_N\352\263\274M_2.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15650_N\352\263\274M_2.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15650_N\352\263\274M_2.java" new file mode 100644 index 0000000..d05135e --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15650_N\352\263\274M_2.java" @@ -0,0 +1,56 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/** + * N개의 값 중에서 M개의 숫자로 만드는 순열 중 오름차순인 순열을 구하는 문제. + */ +public class BOJ_15650_N과M_2 { + + static int N; + static int M; + static int[] pArr; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + pArr = new int[M + 1]; // pArr[0]=0으로 지정해 두기 위해서 크기를 M+1로 할당한다. + visited = new boolean[N + 1]; + + backtrack(1); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == (M + 1)) { + for (int i = 1; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + for (int num = 1; num <= N; num++) { + // 방문하지 않은 숫자이고 + // 순열을 저장해놓은 배열의 바로 직전에 저장한 숫자보다 큰 경우 + if (visited[num] == false && pArr[length - 1] < num) { + visited[num] = true; + pArr[length] = num; // 배열에 숫자 추가 + backtrack(length + 1); + visited[num] = false; + + } + } + + } + +} From 54f0eb5cea310565115c38319d0d8d2914368874 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:49:11 +0900 Subject: [PATCH 069/177] =?UTF-8?q?[15651=20N=EA=B3=BCM(3)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15651_N\352\263\274M_3.java" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15651_N\352\263\274M_3.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15651_N\352\263\274M_3.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15651_N\352\263\274M_3.java" new file mode 100644 index 0000000..073d848 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15651_N\352\263\274M_3.java" @@ -0,0 +1,49 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/** + * N개의 값 중에서 중복을 허용해서 뽑은 M개의 숫자로 순열을 만드는 문제. + */ +public class BOJ_15651_N과M_3 { + + static int N; + static int M; + static int[] pArr; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + pArr = new int[M]; + + backtrack(0); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == M) { + for (int i = 0; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + // 1~N까지의 숫자 순회 + for (int num = 1; num <= N; num++) { + pArr[length] = num; // 배열에 idx=0부터 숫자 추가 + backtrack(length + 1); + + } + + } + +} From b48d5734745abe3d0b307cc5de2c263798667144 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:49:32 +0900 Subject: [PATCH 070/177] =?UTF-8?q?[15652=20N=EA=B3=BCM(4)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15652_N\352\263\274M_4.java" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15652_N\352\263\274M_4.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15652_N\352\263\274M_4.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15652_N\352\263\274M_4.java" new file mode 100644 index 0000000..79d6c80 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15652_N\352\263\274M_4.java" @@ -0,0 +1,51 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/** + * N개의 값 중에서 중복을 허용해서 뽑은 M개의 숫자로 비내림차순 순열을 만드는 문제. + */ +public class BOJ_15652_N과M_4 { + + static int N; + static int M; + static int[] pArr; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + pArr = new int[M + 1]; // pArr[0]=0으로 지정해 두기 위해서 크기를 M+1로 할당한다. + + backtrack(1); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == (M + 1)) { + for (int i = 1; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + // 1~N까지의 숫자 순회 + for (int num = 1; num <= N; num++) { + // 순열을 저장해놓은 배열의 바로 직전에 저장한 숫자보다 크거나 같은 경우 + if (pArr[length - 1] <= num) { + pArr[length] = num; // 배열에 idx=1부터 숫자 추가 + backtrack(length + 1); + } + } + + } + +} From 347f8651f31d789f248baa5ae028b422253e5361 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:49:46 +0900 Subject: [PATCH 071/177] =?UTF-8?q?[15654=20N=EA=B3=BCM(5)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15654_N\352\263\274M_5.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15654_N\352\263\274M_5.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15654_N\352\263\274M_5.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15654_N\352\263\274M_5.java" new file mode 100644 index 0000000..c5fa957 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15654_N\352\263\274M_5.java" @@ -0,0 +1,64 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +/** + * 주어진 N개의 값 중에서 길이가 M인 순열을 사전 순으로 출력하는 문제. + */ +public class BOJ_15654_N과M_5 { + + static int N; + static int M; + static int[] numArr; + static int[] pArr; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + numArr = new int[N]; + StringTokenizer numSt = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + numArr[idx] = Integer.parseInt(numSt.nextToken()); + } + pArr = new int[M]; + visited = new boolean[N]; + Arrays.sort(numArr); // 사전순으로 출력하기 위해서 오름차순으로 정렬 + + backtrack(0); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == M) { + for (int i = 0; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + // 주어진 N개의 숫자 순회 + for (int idx = 0; idx < numArr.length; idx++) { + // 방문하지 않은 숫자면 + if (visited[idx] == false) { + visited[idx] = true; + pArr[length] = numArr[idx]; // 배열에 숫자 추가 + backtrack(length + 1); + visited[idx] = false; + + } + } + + } + +} From c8a93d8ae32ae13efdb6da8999a9e1729a756c39 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:49:59 +0900 Subject: [PATCH 072/177] =?UTF-8?q?[15655=20N=EA=B3=BCM(6)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15655_N\352\263\274M_6.java" | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15655_N\352\263\274M_6.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15655_N\352\263\274M_6.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15655_N\352\263\274M_6.java" new file mode 100644 index 0000000..79283e5 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15655_N\352\263\274M_6.java" @@ -0,0 +1,65 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +/** + * 주어진 N개의 값 중에서 길이가 M인 순열 중 오름차순인 순열을 출력하는 문제. + */ +public class BOJ_15655_N과M_6 { + + static int N; + static int M; + static int[] numArr; + static int[] pArr; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + numArr = new int[N]; + StringTokenizer numSt = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + numArr[idx] = Integer.parseInt(numSt.nextToken()); + } + pArr = new int[M + 1]; // pArr[0]=0으로 지정해 두기 위해서 크기를 M+1로 할당한다. + visited = new boolean[N + 1]; + Arrays.sort(numArr); // 사전순으로 출력하기 위해서 오름차순으로 정렬 + + backtrack(1); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == (M + 1)) { + for (int i = 1; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + // 주어진 N개의 숫자 순회 + for (int idx = 0; idx < numArr.length; idx++) { + // 방문하지 않은 숫자이고 + // 순열을 저장해놓은 배열의 바로 직전에 저장한 숫자보다 큰 경우 + if (visited[idx] == false && pArr[length - 1] < numArr[idx]) { + visited[idx] = true; + pArr[length] = numArr[idx]; // 배열에 숫자 추가 + backtrack(length + 1); + visited[idx] = false; + + } + } + + } + +} From 1ff8e2d5a50d129f11bf3e129ca2e847e62d948e Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:50:10 +0900 Subject: [PATCH 073/177] =?UTF-8?q?[15656=20N=EA=B3=BCM(7)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15656_N\352\263\274M_7.java" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15656_N\352\263\274M_7.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15656_N\352\263\274M_7.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15656_N\352\263\274M_7.java" new file mode 100644 index 0000000..53d1ea6 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15656_N\352\263\274M_7.java" @@ -0,0 +1,58 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +/** + * 주어진 N개의 값 중에서 중복을 허용해서 뽑은 M개의 숫자로 순열을 만드는 문제. + */ +public class BOJ_15656_N과M_7 { + + static int N; + static int M; + static int[] numArr; + static int[] pArr; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + numArr = new int[N]; + StringTokenizer numSt = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + numArr[idx] = Integer.parseInt(numSt.nextToken()); + } + pArr = new int[M]; + Arrays.sort(numArr); // 사전순으로 출력하기 위해서 오름차순으로 정렬 + + backtrack(0); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == M) { + for (int i = 0; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + // 주어진 N개의 숫자 순회 + for (int idx = 0; idx < numArr.length; idx++) { + // 방문하지 않은 숫자면 + pArr[length] = numArr[idx]; // 배열에 idx=0부터 숫자 추가 + backtrack(length + 1); + + } + + } + +} From 1b5d211246c305243134a267a1f442fbf0cf5654 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:50:21 +0900 Subject: [PATCH 074/177] =?UTF-8?q?[15657=20N=EA=B3=BCM(8)=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_15657_N\352\263\274M_8.java" | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15657_N\352\263\274M_8.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15657_N\352\263\274M_8.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15657_N\352\263\274M_8.java" new file mode 100644 index 0000000..68d34a2 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15657_N\352\263\274M_8.java" @@ -0,0 +1,60 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +/** + * 주어진 N개의 값 중에서 중복을 허용해서 뽑은 M개의 숫자로 비내림차순 순열을 만드는 문제. + */ +public class BOJ_15657_N과M_8 { + + static int N; + static int M; + static int[] numArr; + static int[] pArr; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + numArr = new int[N]; + StringTokenizer numSt = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + numArr[idx] = Integer.parseInt(numSt.nextToken()); + } + pArr = new int[M + 1]; // pArr[0]=0으로 지정해 두기 위해서 크기를 M+1로 할당한다. + Arrays.sort(numArr); // 사전순으로 출력하기 위해서 오름차순으로 정렬 + + backtrack(1); + + System.out.println(sb); + + } + + private static void backtrack(int length) { + // 길이가 M인 순열이 완성되면 Stringbuilder에 추가하고 리턴함. + if (length == (M + 1)) { + for (int i = 1; i < pArr.length; i++) { + sb.append(pArr[i] + " "); + } + sb.append('\n'); + return; + } + + // 주어진 N개의 숫자 순회 + for (int idx = 0; idx < numArr.length; idx++) { + // 순열을 저장해놓은 배열의 바로 직전에 저장한 숫자보다 크거나 같은 경우 + if (pArr[length - 1] <= numArr[idx]) { + pArr[length] = numArr[idx]; // 배열에 idx=1부터 숫자 추가 + backtrack(length + 1); + + } + } + + } + +} From 6e4f3153acafffb94a9eaddc53e1e0eee79c66d1 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 20:51:08 +0900 Subject: [PATCH 075/177] =?UTF-8?q?[18290=20NM=EA=B3=BCK(1)=20-=2025.02.16?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_18290_NM\352\263\274K_1.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_18290_NM\352\263\274K_1.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_18290_NM\352\263\274K_1.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_18290_NM\352\263\274K_1.java" new file mode 100644 index 0000000..366e9c0 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_18290_NM\352\263\274K_1.java" @@ -0,0 +1,64 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_18290_NM과K_1 { + static int N; + static int M; + static int K; + static int[][] grid; + static boolean[][] visited; + static int maxPickSum = Integer.MIN_VALUE; + static int currentPickSum = 0; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + K = Integer.parseInt(st.nextToken()); + grid = new int[N][M]; + visited = new boolean[N][M]; + StringTokenizer nums; + + // 격자판 입력받음. + for (int row = 0; row < N; row++) { + nums = new StringTokenizer(br.readLine()); + for (int col = 0; col < M; col++) { + grid[row][col] = Integer.parseInt(nums.nextToken()); + } + } + + backtrack(0, 0, 0); + + System.out.println(maxPickSum); + + } + + public static void backtrack(int pickCount, int prevRow, int prevCol) { + // K개 다 선택한 경우 -> 기존의 K개 더한값의 최댓값과 비교해 더 큰 값을 저장한다 + if (pickCount == K) { + maxPickSum = Math.max(maxPickSum, currentPickSum); + return; + } + + // 직전에 선택한 칸 다음칸부터 시작한다. + for (int r = prevCol >= M ? prevRow + 1 : prevRow; r < N; r++) { + for (int c = prevRow == r ? prevCol : 0; c < M; c++) { + // 선택되지 않은 칸이고, 사방에 선택된 칸이 없을 때 + if (!visited[r][c] && (r - 1 < 0 || !visited[r - 1][c]) && (r + 1 >= N || !visited[r + 1][c]) && (c - 1 < 0 + || !visited[r][c - 1]) && (c + 1 >= M || !visited[r][c + 1])) { + + visited[r][c] = true; + currentPickSum += grid[r][c]; + backtrack(pickCount + 1, r, c + 1); + currentPickSum -= grid[r][c]; + visited[r][c] = false; + } + + } + } + + } +} From d21b1089002b59b65da57dc17953235e49d0b50e Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 16 Feb 2025 21:00:08 +0900 Subject: [PATCH 076/177] =?UTF-8?q?[15654=20N=EA=B3=BC=20M=20(5)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15654/Main.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15654/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15654/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15654/Main.java" new file mode 100644 index 0000000..26313ba --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15654/Main.java" @@ -0,0 +1,64 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + static int[] arr2; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + visited = new boolean[10001]; + arr= new int[M]; + arr2 = new int[N]; + + st = new StringTokenizer(br.readLine()); + for(int i =0;i Date: Sun, 16 Feb 2025 21:03:43 +0900 Subject: [PATCH 077/177] =?UTF-8?q?[15655=20N=EA=B3=BC=20M=20(6)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15655/Main.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15655/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15655/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15655/Main.java" new file mode 100644 index 0000000..d168e5b --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15655/Main.java" @@ -0,0 +1,64 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + static int[] arr2; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + visited = new boolean[10001]; + arr= new int[M]; + arr2 = new int[N]; + + st = new StringTokenizer(br.readLine()); + for(int i =0;i Date: Sun, 16 Feb 2025 21:09:50 +0900 Subject: [PATCH 078/177] =?UTF-8?q?[15656=20N=EA=B3=BC=20M=20(7)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15656/Main.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15656/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15656/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15656/Main.java" new file mode 100644 index 0000000..e0ddbb0 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15656/Main.java" @@ -0,0 +1,64 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + static int[] arr2; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + visited = new boolean[10001]; + arr= new int[M]; + arr2 = new int[N]; + + st = new StringTokenizer(br.readLine()); + for(int i =0;i Date: Sun, 16 Feb 2025 21:12:41 +0900 Subject: [PATCH 079/177] =?UTF-8?q?[15657=20N=EA=B3=BC=20M=20(8)=20-=2025.?= =?UTF-8?q?02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_15657/Main.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15657/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15657/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15657/Main.java" new file mode 100644 index 0000000..7d86d6f --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_15657/Main.java" @@ -0,0 +1,64 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int[] arr; + static int[] arr2; + static boolean[] visited; + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + visited = new boolean[10001]; + arr= new int[M]; + arr2 = new int[N]; + + st = new StringTokenizer(br.readLine()); + for(int i =0;i Date: Sun, 16 Feb 2025 22:26:11 +0900 Subject: [PATCH 080/177] =?UTF-8?q?[18290=20NM=EA=B3=BC=20K=20(1)=20-=2025?= =?UTF-8?q?.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YuRi/Yuri_18290/Main.java" | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_18290/Main.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_18290/Main.java" "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_18290/Main.java" new file mode 100644 index 0000000..91ae129 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/YuRi/Yuri_18290/Main.java" @@ -0,0 +1,89 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int[][] arr; + static int Max; + static boolean[][] visited; + static int[] dx = {-1,1,0,0}; + static int[] dy = {0,0,-1,1}; + + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + int K = Integer.parseInt(st.nextToken()); + + visited = new boolean[N][M]; + arr = new int[N][M]; + Max = Integer.MIN_VALUE; + + + for(int i =0;i=n||ny<0||ny>=m) continue; + + if(visited[nx][ny]) { + flag=false; + break; + } + } + if(flag) { + visited[i][j] = true; + nm(n,m,k,now+1,sum+arr[i][j]); + visited[i][j] = false; + } + } + } + + } + + return; + } + +} From 46ea007d097753ca5c3bebd47376e57f4d4128b4 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 23:53:36 +0900 Subject: [PATCH 081/177] =?UTF-8?q?[14500=20=ED=85=8C=ED=8A=B8=EB=A1=9C?= =?UTF-8?q?=EB=AF=B8=EB=85=B8=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\241\234\353\257\270\353\205\270.java" | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14500_\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14500_\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14500_\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.java" new file mode 100644 index 0000000..75c1c84 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14500_\355\205\214\355\212\270\353\241\234\353\257\270\353\205\270.java" @@ -0,0 +1,85 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/** + * [idea] + * 백트래킹을 하며 4칸을 선택하다 보면 + * 5 종류의 테트로미노를 회전, 대칭시킨 모양이 된다. + * (ㅜ 모양의 테트로미노는 따로 처리해줘야 한다.) + */ +public class BOJ_14500_테트로미노 { + static int n; + static int m; + static int[][] grid; + static boolean[][] visited; + static int maxPutSum = Integer.MIN_VALUE; + // 사방 + static int[] dx = { -1, 1, 0, 0 }; + static int[] dy = { 0, 0, -1, 1 }; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + st = new StringTokenizer(br.readLine()); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + grid = new int[n][m]; + visited = new boolean[n][m]; + + // 격자판 입력받음. + for (int row = 0; row < n; row++) { + st = new StringTokenizer(br.readLine()); + for (int col = 0; col < m; col++) { + grid[row][col] = Integer.parseInt(st.nextToken()); + } + } + + // 모든 칸 순회 + for (int row = 0; row < n; row++) { + for (int col = 0; col < m; col++) { + visited[row][col] = true; + backTrack(row, col, grid[row][col], 1); + visited[row][col] = false; + } + } + + System.out.println(maxPutSum); + + } + + static void backTrack(int row, int col, int sum, int count) { + // 테트로미노 완성 시 수들의 합 계산 + if (count == 4) { + maxPutSum = Math.max(maxPutSum, sum); + return; + } + + // 사방 탐색 + for (int i = 0; i < 4; i++) { + int curRow = row + dx[i]; + int curCol = col + dy[i]; + + // grid 벗어나는 경우 + if (curRow < 0 || curRow >= n || curCol < 0 || curCol >= m) { + continue; + } + + // 방문하지 않은 칸인 경우 + if (visited[curRow][curCol] == false) { + + // ㅜ 모양 테트로미노를 위해 2번째 칸에서 백트래킹 한 번 더 수행 + if (count == 2) { + visited[curRow][curCol] = true; + backTrack(row, col, sum + grid[curRow][curCol], count + 1); + visited[curRow][curCol] = false; + } + + visited[curRow][curCol] = true; + backTrack(curRow, curCol, sum + grid[curRow][curCol], count + 1); + visited[curRow][curCol] = false; + } + } + } +} From 90101c04eb33e0756ce2dc01645504f69fda8751 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 23:54:13 +0900 Subject: [PATCH 082/177] =?UTF-8?q?[6064=20=EC=B9=B4=EC=9E=89=EB=8B=AC?= =?UTF-8?q?=EB=A0=A5=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\236\211\353\213\254\353\240\245.java" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_6064_\354\271\264\354\236\211\353\213\254\353\240\245.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_6064_\354\271\264\354\236\211\353\213\254\353\240\245.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_6064_\354\271\264\354\236\211\353\213\254\353\240\245.java" new file mode 100644 index 0000000..5ce9cec --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_6064_\354\271\264\354\236\211\353\213\254\353\240\245.java" @@ -0,0 +1,46 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_6064_카잉달력 { + public static void main(String[] args) throws IOException { + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int T = Integer.parseInt(br.readLine()); + + for (int tc = 0; tc < T; tc++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int m = Integer.parseInt(st.nextToken()); + int n = Integer.parseInt(st.nextToken()); + int x = Integer.parseInt(st.nextToken()) - 1; // 나머지 연산 사용으로 인해 0부터 시작하므로 -1해줌. + int y = Integer.parseInt(st.nextToken()) - 1; + + boolean found = false; + + int lcm = (m / gcd(m, n)) * n; // m과 n의 최소공배수 구함 + // m과 n의 최소공배수를 종료조건으로 설정. + for (int year = x; year < lcm; year += m) { + // 해당하는 해인 경우 출력하고 끝냄 + if (year % n == y) { + System.out.println(year + 1); + found = true; + break; + } + } + + // x:y로 표현되는 해를 못 찾은 경우 + if (found == false) { + System.out.println(-1); + } + + } + } + + // 최대공약수 구함 + public static int gcd(int a, int b) { + if (b == 0) + return a; + return gcd(b, a % b); + } +} From cf76926ea4543bbe32df5d90333e514837b1aaf6 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 23:54:52 +0900 Subject: [PATCH 083/177] =?UTF-8?q?[1748=20=EC=88=98=20=EC=9D=B4=EC=96=B4?= =?UTF-8?q?=20=EC=93=B0=EA=B8=B01=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\226\264\354\223\260\352\270\2601.java" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1748_\354\210\230\354\235\264\354\226\264\354\223\260\352\270\2601.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1748_\354\210\230\354\235\264\354\226\264\354\223\260\352\270\2601.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1748_\354\210\230\354\235\264\354\226\264\354\223\260\352\270\2601.java" new file mode 100644 index 0000000..380fef6 --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1748_\354\210\230\354\235\264\354\226\264\354\223\260\352\270\2601.java" @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class BOJ_1748_수이어쓰기1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int resultLength = 0; + + int nLength = String.valueOf(n).length(); + + // (주어진 n의 자릿수-1)까지의 길이를 구함 + for (int digit = 1; digit < nLength; digit++) { + resultLength += 9 * Math.pow(10, digit - 1) * digit; + } + + // (주어진 n의 자릿수 길이)와 자릿수가 같은 숫자들의 길이를 마저 더함 + int startNum = (int) Math.pow(10, nLength - 1); + resultLength += (n - startNum + 1) * nLength; + + System.out.println(resultLength); + + } +} From c9dabd3be09aaa43f06592d58c8947f24d2e87b5 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Feb 2025 23:55:29 +0900 Subject: [PATCH 084/177] =?UTF-8?q?[9095=201,2,3=20=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=2025.02.16]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\215\224\355\225\230\352\270\260.java" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_9095_123\353\215\224\355\225\230\352\270\260.java" diff --git "a/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_9095_123\353\215\224\355\225\230\352\270\260.java" "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_9095_123\353\215\224\355\225\230\352\270\260.java" new file mode 100644 index 0000000..fb575bf --- /dev/null +++ "b/2\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_9095_123\353\215\224\355\225\230\352\270\260.java" @@ -0,0 +1,26 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_9095_123더하기 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int T = Integer.parseInt(br.readLine()); + + for (int tc = 0; tc < T; tc++) { + int n = Integer.parseInt(br.readLine()); + int[] dp = new int[12]; + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + + for (int i = 4; i <= n; i++) { + dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]; + } + + System.out.println(dp[n]); + } + } + +} From 1f5242d27459e4254a3c553098d7f706fd937df7 Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 17 Feb 2025 22:38:24 +0900 Subject: [PATCH 085/177] =?UTF-8?q?[13458=20=EC=8B=9C=ED=97=98=EA=B0=90?= =?UTF-8?q?=EB=8F=85=20-=2025.02.17]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 +++++++++++ .../ChulHyeon/.idea/.gitignore" | 8 ++++ .../ChulHyeon/src/BOJ13458/Main.java" | 48 +++++++++++++++++++ .../ChulHyeon/src/BOJ2146/Main.java" | 0 4 files changed, 85 insertions(+) create mode 100644 "A\355\230\225\353\214\200\353\271\204/ChulHyeon/.gitignore" create mode 100644 "A\355\230\225\353\214\200\353\271\204/ChulHyeon/.idea/.gitignore" create mode 100644 "A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ13458/Main.java" rename "A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" => "A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2146/Main.java" (100%) diff --git "a/A\355\230\225\353\214\200\353\271\204/ChulHyeon/.gitignore" "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/A\355\230\225\353\214\200\353\271\204/ChulHyeon/.idea/.gitignore" "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ13458/Main.java" "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ13458/Main.java" new file mode 100644 index 0000000..05a06cf --- /dev/null +++ "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ13458/Main.java" @@ -0,0 +1,48 @@ +package BOJ13458; + +import java.util.Scanner; + +/* +총 N개의 시험장이 있고, 각각의 시험장마다 응시자들이 있다. i번 시험장에 있는 응시자의 수는 Ai명이다. + +감독관은 총감독관과 부감독관으로 두 종류가 있다. 총감독관은 한 시험장에서 감시할 수 있는 응시자의 수가 B명이고, 부감독관은 한 시험장에서 감시할 수 있는 응시자의 수가 C명이다. + +각각의 시험장에 총감독관은 오직 1명만 있어야 하고, 부감독관은 여러 명 있어도 된다. + +각 시험장마다 응시생들을 모두 감시해야 한다. 이때, 필요한 감독관 수의 최솟값을 구하는 프로그램을 작성하시오. +*/ + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); // n 개의 시험장 + // 각 시험장에 있는 응시자 수 + int[] arr = new int[n]; + for(int i = 0; i < n; i++) { + arr[i] = sc.nextInt(); + } + int B = sc.nextInt(); // 총 시험 감독관이 한 반에서 케어 가능한 응시자 수 + int C = sc.nextInt(); // 부 시험 감독관이 한 반에서 케어 가능한 응시자 수 + // 각 시험장마다 응시생을 모두 감독하기 위해 필요한 감독관의 ((최소 수))를 출력한다. + // 총 감독관은 한 반에 하나 // 부 감독관은 여러명 있을 수 있음 + long result = 0; + for(int i = 0; i < n; i++) { + // 총 감독관 하나 넣기 + result++; + if(arr[i] - B <= 0) // 총 감독관 하나로 되는 경우 + { + continue; + } + else + { + arr[i] = arr[i] - B; + result = result + (arr[i] / C); + if(arr[i] % C == 0) + continue; + else + result++; + } + } + System.out.println(result); + } +} diff --git "a/A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2146/Main.java" similarity index 100% rename from "A\355\230\225\353\214\200\353\271\204/ChulHyeon/BOJ2146/Main.java" rename to "A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2146/Main.java" From e7e3a2de1a32894d45d875434c0a4debf2840246 Mon Sep 17 00:00:00 2001 From: munncoding Date: Tue, 18 Feb 2025 12:33:32 +0900 Subject: [PATCH 086/177] =?UTF-8?q?[2458=20=ED=82=A4=20=EC=88=9C=EC=84=9C?= =?UTF-8?q?=20-=2025.02.18]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ2458/Main.java" | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 "A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2458/Main.java" diff --git "a/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2458/Main.java" "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2458/Main.java" new file mode 100644 index 0000000..40d970e --- /dev/null +++ "b/A\355\230\225\353\214\200\353\271\204/ChulHyeon/src/BOJ2458/Main.java" @@ -0,0 +1,78 @@ +package BOJ2458; + +import java.util.*; + +public class Main { + static List> parent; + static List> child; + static boolean[] visit; + + public static void bfs(int start, int n) { + Queue q = new LinkedList<>(); + visit[start] = true; + q.add(start); + + while (!q.isEmpty()) { + int now = q.poll(); + for (int i = 0; i < parent.get(now).size(); i++) { + int p = parent.get(now).get(i); + if (visit[p]) // 이미 방문 했으면 + continue; + q.add(p); + visit[p] = true; + } + } + + q.add(start); + while (!q.isEmpty()) { + int now = q.poll(); + for (int i = 0; i < child.get(now).size(); i++) { + int c = child.get(now).get(i); + if (visit[c]) // 이미 방문 했으면 + continue; + q.add(c); + visit[c] = true; + } + } + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int result = 0; + + int n = sc.nextInt(); + parent = new ArrayList<>(n + 1); + child = new ArrayList<>(n + 1); + + for (int i = 0; i <= n; i++) { + parent.add(new ArrayList<>()); + child.add(new ArrayList<>()); + } + + visit = new boolean[n + 1]; + + int M = sc.nextInt(); + for (int k = 0; k < M; k++) { + int first = sc.nextInt(); + int second = sc.nextInt(); + child.get(first).add(second); + parent.get(second).add(first); + } + + for (int i = 1; i <= n; i++) { // 다 탐색 가능한지 확인 + Arrays.fill(visit, false); + bfs(i, n); + boolean check = true; + for (int j = 1; j <= n; j++) { + if (!visit[j]) { + check = false; + break; + } + } + if (check) { + result++; + } + } + System.out.println(result); + } +} From b81fcc10ca826fd3f5eaeac0f867b2fc9d9734b3 Mon Sep 17 00:00:00 2001 From: munncoding Date: Wed, 19 Feb 2025 17:29:47 +0900 Subject: [PATCH 087/177] =?UTF-8?q?[SWEA=20=EC=88=9C=EC=97=B4=20-=2025.02.?= =?UTF-8?q?19]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\271\200\354\262\240\355\230\204.java" | 83 ++++++++++++++ ...\352\271\200\354\262\240\355\230\204.java" | 83 ++++++++++++++ ...\352\271\200\354\262\240\355\230\204.java" | 108 ++++++++++++++++++ 3 files changed, 274 insertions(+) create mode 100644 "SWEA/ChulHyeon/SWEA_1210_Ladder1_\352\271\200\354\262\240\355\230\204.java" create mode 100644 "SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" create mode 100644 "SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" diff --git "a/SWEA/ChulHyeon/SWEA_1210_Ladder1_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_1210_Ladder1_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..2ab07d2 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_1210_Ladder1_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,83 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer;; + +/* + * 2가 도착점인데 거기를 시작점으로 해서 탐색하자 + * 1. 아래로 내려갈 필요가 없으므로 위, 왼, 오 로 탐색 할 것. + * 2. 왼쪽 혹은 오른쪽에 사다리가 있을 경우 위로 가는 것보다 사다리를 타는게 우선순위가 높으므로 dir 배열에서 위를 맨 나중에 : 왼->오->위 + * 3. nowR 현재 탐색 행이 0일 때 반복문 종료 해서 nowCol을 리턴 + * */ + +public class SWEA_1210_Ladder1_김철현 { + + static int[][] map = new int[100][100]; // 사다리 맵 저장 + static boolean[][] visit = new boolean[100][100]; // 방문 기록 저장 + static int dirR[] = {0,0,-1}; // 왼 오 위 + static int dirC[] = {-1,1,0}; + + + public static void main(String[] args)throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + for(int testCase = 1; testCase <= 10;testCase++) + { + // 처음에 쓰레기값 하나 입력 + br.readLine(); + // 초기화 + for(int i=0;i<100;i++) + { + for(int j=0;j<100;j++) + { + visit[i][j] = false; + } + } + // 목표 지점의 row col + int nowR = 0; + int nowC = 0; + // 입력 받을 거야 + for(int row = 0;row<100;row++) + { + st = new StringTokenizer(br.readLine().trim()); + for(int col = 0;col<100;col++) + { + map[row][col] = Integer.parseInt(st.nextToken()); + if(map[row][col] == 2) + { + nowR = row; + nowC = col; + } + } + } + nowR--; // 시작은 한칸 위에서 시작 + // 왼쪽 오른쪽에 사다리 없으면 계속 올라가고 + while(nowR > 0) + { + for(int dir = 0;dir<3;dir++) + { + int nextR = nowR + dirR[dir]; + int nextC = nowC + dirC[dir]; + // 범위 체크 + if(nextR < 0 || nextC < 0 || nextR >= 100 || nextC >= 100) + { + continue; + } + // 이동 가능 체크 + if(map[nextR][nextC] == 0) + continue; + // 방문 체크 + if(visit[nextR][nextC]) + continue; + visit[nextR][nextC] = true; + nowR = nextR; + nowC = nextC; + } + } + sb.append("#").append(testCase).append(" ").append(nowC).append('\n'); + } + System.out.println(sb.toString()); + + } +} diff --git "a/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..fee2bb6 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,83 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* + * 1. (0,0) 에서 시작해서 쭉 돌거야 + * 2. dirR dirC 배열을 사용, 순서는 오른쪽, 아래, 왼쪽, 위 + * 3. map[nextR][nextC] == 0 일 동안 while 로 반복 + * 4. 위 조건에 안맞으면 방향 꺽어줘야 하는데 (nowDir + 1) % 4 하면 자연스럽게 방향전환 될 듯 + * 5. 끝나는 조건은 한 칸 채울 때마다 cnt++ 해서 입력받은 n*n 과 같아지면 출력하고 프로그램 종료 하도록 하자 + * + * + * ******** 방향을 바꿔줘야 하는 경우 + * 1. 범위를 벗어난 경우 + * 2. 다음칸이 이미 채워진 경우 + * 이 두 경우 방향을 바꿔줌과 동시에 현재 위치 (nowR, nowC) 도 갱신 해줘야 한다. + * */ + +public class Solution { + + static int dirR[] = {0,1,0,-1}; + static int dirC[] = {1,0,-1,0}; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + int T = Integer.parseInt(br.readLine().trim()); + for(int testCase = 1; testCase <=T;testCase++) + { + sb.append("#").append(testCase).append('\n'); + int mapSize = Integer.parseInt(br.readLine().trim()); + int[][] map = new int[mapSize][mapSize]; + int dir = 0; + int fillCnt = 1; + int nowR = 0; + int nowC = 0; + while(true) + { + if(fillCnt == mapSize * mapSize + 1) // 모든 칸을 채웠을 경우 출력하고 종료 + { + for(int row=0;row=mapSize||nextC >= mapSize) + { + dir = (dir + 1) % 4; + nowR = nowR + dirR[dir]; + nowC = nowC + dirC[dir]; + continue; + } + // 2. 다음 칸이 이미 채워진 경우 + if(map[nextR][nextC] != 0) + { + dir = (dir + 1) % 4; + nowR = nowR + dirR[dir]; + nowC = nowC + dirC[dir]; + continue; + } + // 현재 위치 갱신 + nowR = nextR; + nowC = nextC; + } + } + System.out.println(sb.toString()); + } +} diff --git "a/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..a6e5e55 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,108 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* + * 이기는 경우 / 지는 경우 출력 + * 1. dfs 재귀로 9칸 짜리 배열 하나에 상대방의 순열을 저장 + * 2. dfs 탈출조건에서 내 카드와 상대 카드를 비교하여 내 합산 점수와 상대 합산점수를 저장 + * 3. 합산 점수를 기준으로 승/무승부/패 각각 판단 + * */ + + +public class Solution { + + static final int CARD_CNT = 9; + + static int myCard[] = new int[9]; + static int youCard[] = new int[9]; + static int youCardPermutation[] = new int[9]; + static boolean visit[] = new boolean[9]; + + static int winRate = 0; + static int loseRate = 0; + + // 내 카드 조합과 상대 카드조합 간의 대결 + // 내가 이기면 양수, 상대가 이기면 음수, 무승부면 0 리턴 + static int fight() + { + int myScore = 0; + int youScore = 0; + for(int idx = 0; idx youCardPermutation[idx]) + { + myScore = myScore + myCard[idx] + youCardPermutation[idx]; + } + else if(myCard[idx] < youCardPermutation[idx]) { + youScore = youScore + myCard[idx] + youCardPermutation[idx]; + } + } + return myScore - youScore; + } + + static void dfs(int nowCnt) + { + if(nowCnt == CARD_CNT) + { + if(fight() > 0) + winRate++; + else if(fight() < 0) + loseRate++; + return; + } + for(int idx = 0; idx < CARD_CNT; idx++) + { + if(visit[idx]) + continue; + youCardPermutation[nowCnt] = youCard[idx]; + visit[idx] = true; + dfs(nowCnt + 1); + visit[idx] = false; + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + int T = Integer.parseInt(br.readLine().trim()); + for(int testCase = 1; testCase <=T;testCase++) + { + // 초기화 + winRate = 0; + loseRate = 0; + // 내 카드 리스트 저장 + st = new StringTokenizer(br.readLine().trim()); + for(int idx=0;idx Date: Wed, 19 Feb 2025 23:52:36 +0900 Subject: [PATCH 088/177] =?UTF-8?q?[14501=20=ED=87=B4=EC=82=AC=ED=95=98?= =?UTF-8?q?=EA=B3=A0=EC=8B=B6=EB=8B=A4=20-=2025.02.19]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Main.java" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/Main.java" new file mode 100644 index 0000000..78adf1d --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/Main.java" @@ -0,0 +1,33 @@ +import java.io.*; +import java.util.Arrays; +import java.util.Comparator; +import java.util.StringTokenizer; +public class Main { + static int[][] talk; + static boolean[] visited; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + talk = new int[N][2]; + visited = new boolean[N]; + for(int i =0; i=0;day--) { + endDay = talk[day][0]; + if(endDay<=N ) { + dp[day] = Math.max(talk[day][1]+dp[endDay],dp[day+1]); + } + else { + dp[day] = dp[day+1]; + } + } + System.out.println(dp[0]); +} +} From f3ef559e8c27e98c5c4dd4dd1dd3aee826a3e62d Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Feb 2025 22:37:25 +0900 Subject: [PATCH 089/177] =?UTF-8?q?[SWEA1218=20=EA=B4=84=ED=98=B8=EC=A7=9D?= =?UTF-8?q?=EC=A7=93=EA=B8=B0=20-=2025.02.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 ++++++++ .../ChulHyeon/.idea/.gitignore" | 8 +++ .../ChulHyeon/src/BOJ1759/Main.java" | 25 +++++++ SWEA/ChulHyeon/.idea/.gitignore | 8 +++ ...\352\271\200\354\262\240\355\230\204.java" | 71 +++++++++++++++++++ ...\352\271\200\354\262\240\355\230\204.java" | 2 +- ...\352\271\200\354\262\240\355\230\204.java" | 2 +- .../out/production/ChulHyeon/.idea/.gitignore | 8 +++ 8 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" create mode 100644 SWEA/ChulHyeon/.idea/.gitignore create mode 100644 "SWEA/ChulHyeon/SWEA_1218_\352\264\204\355\230\270\354\247\235\354\247\223\352\270\260_\352\271\200\354\262\240\355\230\204.java" create mode 100644 SWEA/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" new file mode 100644 index 0000000..6527c7f --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" @@ -0,0 +1,25 @@ +package BOJ1759; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int L; + static int C; + static char[] arr; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + st = new StringTokenizer(br.readLine()); + L = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + arr = new char[L]; + for (int i = 0; i < L; i++) { + + } + } +} diff --git a/SWEA/ChulHyeon/.idea/.gitignore b/SWEA/ChulHyeon/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/SWEA/ChulHyeon/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/SWEA/ChulHyeon/SWEA_1218_\352\264\204\355\230\270\354\247\235\354\247\223\352\270\260_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_1218_\352\264\204\355\230\270\354\247\235\354\247\223\352\270\260_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..59a3e38 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_1218_\352\264\204\355\230\270\354\247\235\354\247\223\352\270\260_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,71 @@ +/* +* ( < { [ 왼쪽 꺽쇠들은 스택에 넣고 +* ) > } ] 오른쪽 꺽쇠들은 스택의 top과 비교해서 pop 해야함 +* +* 유효하지 않아 결과가 0 으로 출력될 경우 +* 1. stack 의 top 과 현재 비교한 토큰의 짝이 맞지 않을 경우 +* 2. 비교를 하려고 봤더니 stack이 비어있을 경우 +* 3. 문자열이 끝났는데 stack에 뭔가 남아있을 경우 +* +* */ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Stack; +import java.util.StringTokenizer; + +public class SWEA_1218_괄호짝짓기_김철현 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + for (int testCase = 1; testCase <= 10; testCase++) { + Stack stack = new Stack<>(); + br.readLine(); // 한 번 버리기 + String inputStr = br.readLine(); + + int result = 1; + for (int idx = 0; idx < inputStr.length(); idx++) { + char ch = inputStr.charAt(idx); + + if (ch == '(' || ch == '{' || ch == '[' || ch == '<') { + stack.push(ch); + } + //1. stack 의 top 과 현재 비교한 토큰의 짝이 맞지 않을 경우 + //2. 비교를 하려고 봤더니 stack이 비어있을 경우 + else if (ch == ')') { + if (stack.isEmpty() || stack.pop() != '(') { + result = 0; + break; + } + } + else if (ch == '}') { + if (stack.isEmpty() || stack.pop() != '{') { + result = 0; + break; + } + } + else if (ch == ']') { + if (stack.isEmpty() || stack.pop() != '[') { + result = 0; + break; + } + } + else if (ch == '>') { + if (stack.isEmpty() || stack.pop() != '<') { + result = 0; + break; + } + } + } + //3. 문자열이 끝났는데 stack에 뭔가 남아있을 경우 + if(!stack.isEmpty()){ + result = 0; + } + sb.append("#").append(testCase).append(" ").append(result).append("\n"); + } + System.out.println(sb.toString()); + } +} diff --git "a/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" index fee2bb6..5e962c8 100644 --- "a/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" +++ "b/SWEA/ChulHyeon/SWEA_1954_\353\213\254\355\214\275\354\235\264\354\210\253\354\236\220_\352\271\200\354\262\240\355\230\204.java" @@ -17,7 +17,7 @@ * 이 두 경우 방향을 바꿔줌과 동시에 현재 위치 (nowR, nowC) 도 갱신 해줘야 한다. * */ -public class Solution { +public class SWEA_1954_달팽이숫자_김철현 { static int dirR[] = {0,1,0,-1}; static int dirC[] = {1,0,-1,0}; diff --git "a/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" index a6e5e55..abe9691 100644 --- "a/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" +++ "b/SWEA/ChulHyeon/SWEA_6808_\352\267\234\354\230\201\354\235\264\354\231\200\354\235\270\354\230\201\354\235\264\354\235\230\354\271\264\353\223\234\352\262\214\354\236\204_\352\271\200\354\262\240\355\230\204.java" @@ -11,7 +11,7 @@ * */ -public class Solution { +public class SWEA_6808_규영이와인영이의카드게임_김철현 { static final int CARD_CNT = 9; diff --git a/SWEA/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore b/SWEA/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/SWEA/ChulHyeon/out/production/ChulHyeon/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml From af5e72417d61a8b4e7a3860aa7bcfed9d1576f2d Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Feb 2025 23:02:22 +0900 Subject: [PATCH 090/177] =?UTF-8?q?[11660=20=EA=B5=AC=EA=B0=84=ED=95=A9?= =?UTF-8?q?=EA=B5=AC=ED=95=98=EA=B8=B05=20-=2025.02.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ11660/Main.java" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" new file mode 100644 index 0000000..6b0f059 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" @@ -0,0 +1,63 @@ +package BOJ11660; + +/* +* +* mapSize / testCase 입력 +* map 입력 +* testCase 입력 +* +* 부분합을 사용해야 하므로 2차원 배열 0은 냅두고 1부터 시작하는것을 map으로 한다. +* 1. map 을 입력 받는다. +* 2. sum 2차원 배열을 두고 1행 가로열을 채운다 +* 3. 1열 세로열을 채운다 +* 4. 2 2 3 4 로 입력이 들어왔다면 sum[3][4] - sum[2][2] 가 정답! +* +* */ + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main{ + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + st = new StringTokenizer(br.readLine()); + int mapSize= Integer.parseInt(st.nextToken()); // 맵의 크기 + int testCase = Integer.parseInt(st.nextToken()); // 테스트케이스 개수 + + int map[][] = new int[mapSize + 1][mapSize + 1]; // 맵 + int sum[][] = new int[mapSize + 1][mapSize + 1]; // 누적합 배열 + + // 1. 맵 입력 + for(int row = 1; row <= mapSize; row++) { + st= new StringTokenizer(br.readLine()); + for(int col = 1; col <= mapSize; col++) { + map[row][col] = Integer.parseInt(st.nextToken()); + } + } + // 4. 누적합 계산 + for(int row = 1; row <= mapSize; row++) { + for(int col = 1; col <= mapSize; col++) { + sum[row][col] = map[row][col] + sum[row - 1][col] + sum[row][col - 1] - sum[row-1][col-1]; + } + } + // 5. 테케 만큼 구해서 출력 + while((testCase--) > 0) + { + st = new StringTokenizer(br.readLine()); + int firstR = Integer.parseInt(st.nextToken()); + int firstC = Integer.parseInt(st.nextToken()); + int secondR = Integer.parseInt(st.nextToken()); + int secondC = Integer.parseInt(st.nextToken()); + // 누적합 출력 이 때 내 기준 위에 줄 싹, 왼쪽 줄 싹 빼주고 11시방향 대각선 부분은 2번 빼준 거므로 한번 더해준다. + sb.append(sum[secondR][secondC] - sum[firstR - 1][secondC] - sum[secondR][firstC-1] + + sum[firstR-1][firstC-1]).append('\n'); + } + System.out.println(sb.toString()); + } +} From 44fbad437bb04810575357faec7b98576529318e Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Feb 2025 23:03:59 +0900 Subject: [PATCH 091/177] =?UTF-8?q?Update=20BOJ=5F11660=5F=EA=B5=AC?= =?UTF-8?q?=EA=B0=84=ED=95=A9=EA=B5=AC=ED=95=98=EA=B8=B05=5F=EA=B9=80?= =?UTF-8?q?=EC=B2=A0=ED=98=84.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" => "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" (97%) diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" similarity index 97% rename from "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" rename to "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" index 6b0f059..fbda4a6 100644 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/Main.java" +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" @@ -20,7 +20,7 @@ import java.io.InputStreamReader; import java.util.StringTokenizer; -public class Main{ +public class BOJ_11660_구간합구하기5_김철현 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); From cb78738d1b0c96e49d6757102c8ee225d1e33da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Fri, 21 Feb 2025 22:42:39 +0900 Subject: [PATCH 092/177] =?UTF-8?q?[9095=201,2,3=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=2025.02.21]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ14501/Main.java" | 0 .../BOJ9095/Main.java" | 67 +++++++++++++++++++ 2 files changed, 67 insertions(+) rename "2\354\233\224 3\354\243\274\354\260\250/Main.java" => "2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" (100%) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/Main.java" rename to "2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" new file mode 100644 index 0000000..19110e8 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" @@ -0,0 +1,67 @@ +package BOJ9095; + +/* + * 문제 1,2,3 더하기 +정수 4를 1, 2, 3의 합으로 나타내는 방법은 총 7가지가 있다. 합을 나타낼 때는 수를 1개 이상 사용해야 한다. + +1+1+1+1 +1+1+2 +1+2+1 +2+1+1 +2+2 +1+3 +3+1 +정수 n이 주어졌을 때, n을 1, 2, 3의 합으로 나타내는 방법의 수를 구하는 프로그램을 작성하시오. + +입력 +첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 정수 n이 주어진다. n은 양수이며 11보다 작다. + +출력 +각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다. + +예제 입력 1 +3 +4 +7 +10 +예제 출력 1 +7 +44 +274 + +1:1 = 1 | +2:2 = 1+1| 2 +3:4 = 1+1+1 | 1+2, 2+1 | 3 +4:7 = 1+3|, 2+2, 1+1+2 | 1+2+1,2+1+1,3+1,1+1+1+1 +5:13 = 1+1+1+1+1 |1+1+1+2 * 4 |1+1+3 *3 , 2+2+1, *3 | 3+2, 2+3 | + +1,2,4,7,13 + +N을 만드는 법 : N-1 읆 만들고 1을 더한다. N-2를 만들고 2를 더한다. N-3을 더하고 3을 더한다. + + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +public class Main { + static int[] dp = new int[12]; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int T = Integer.parseInt(br.readLine()); + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i = 4; i<12;i++) { + dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; + } + for (int test_case = 1 ; test_case<=T;test_case++) { + int n = Integer.parseInt(br.readLine()); + bw.write(dp[n]+"\n"); + } + bw.flush(); + + } +} From 9a161f2684133cc02f6ff74a590e667e12451436 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Fri, 21 Feb 2025 23:03:27 +0900 Subject: [PATCH 093/177] =?UTF-8?q?[14501=20=ED=87=B4=EC=82=AC=20-=2025.02?= =?UTF-8?q?.21]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_14501_\355\207\264\354\202\254.java" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" new file mode 100644 index 0000000..09b9d0b --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" @@ -0,0 +1,55 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_14501_퇴사 { + static int n; + static int[] days; + static int[] fee; + static int maxFee; + static int totalFee; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + n = Integer.parseInt(br.readLine()); + days = new int[n]; + fee = new int[n]; + maxFee = 0; + totalFee = 0; + + // 기간과 금액 입력받음. + for (int idx = 0; idx < n; idx++) { + st = new StringTokenizer(br.readLine()); + days[idx] = Integer.parseInt(st.nextToken()); + fee[idx] = Integer.parseInt(st.nextToken()); + } + + // 재귀호출 Start + acceptCounsel(0); + + System.out.println(maxFee); + + } + + public static void acceptCounsel(int dayIdx) { + // 종료조건 + if (dayIdx >= n) { + maxFee = Math.max(maxFee, totalFee); + return; + } + + // 1. dayIdx날 선택하는 경우 + if (dayIdx + days[dayIdx] <= n) { + + totalFee += fee[dayIdx]; + acceptCounsel(dayIdx + days[dayIdx]); + totalFee -= fee[dayIdx]; + } + + // 2. dayIdx날에 상담을 선택하지 않고 다음날로 넘어감. + acceptCounsel(dayIdx + 1); + + } +} From 05c1bacd7e274b2e9c0843efd96dac0dd0ff0c8d Mon Sep 17 00:00:00 2001 From: munncoding Date: Sat, 22 Feb 2025 21:16:14 +0900 Subject: [PATCH 094/177] [SWEA 3421 - 25.02.22] --- ...\352\271\200\354\262\240\355\230\204.java" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "SWEA/ChulHyeon/SWEA_3421_\354\210\230\354\240\234\353\262\204\352\261\260\354\236\245\354\235\270_\352\271\200\354\262\240\355\230\204.java" diff --git "a/SWEA/ChulHyeon/SWEA_3421_\354\210\230\354\240\234\353\262\204\352\261\260\354\236\245\354\235\270_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_3421_\354\210\230\354\240\234\353\262\204\352\261\260\354\236\245\354\235\270_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..c7927e1 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_3421_\354\210\230\354\240\234\353\262\204\352\261\260\354\236\245\354\235\270_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,79 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* +* +* 재귀로 돌릴건데 같이 있는 것에 대한 제한이 걸린 놈들 처리가 문제임 +* 2차원 배열을 하나 추가로 두자!! +* ban[1][2] = true 가 의미하는 것은 +* 1 재료와 2 재료가 동시에 같은 곳에 들어갈 수 없다는 것이다. +* +* */ + + +public class SWEA_3421_수제버거장인_김철현 { + + static boolean[][] ban; + static boolean[] check; + + static int ingredientCnt; + static int conditionCnt; + static int result; + + static void dfs(int nowIdx){ + if(nowIdx > ingredientCnt){ + // 기저조건에 닿으면 출력 + result++; + return; + } + // 1. 현재 재료 선택 x + dfs(nowIdx +1); + + // 2. 현재 재료를 선택할 수 있는지 확인 + boolean canSelect = true; + for (int i = 1; i <= ingredientCnt; i++) { + if (check[i] && ban[nowIdx][i]) { // for 문을 돌면서 체크되어있는데(이미 재료로 들어가 있는데) 나랑 ban되어 있다면 + canSelect = false; + break; + } + } + + // 3. 선택 가능한 경우 선택하고 탐색 + if (canSelect) { + check[nowIdx] = true; + dfs(nowIdx + 1); + check[nowIdx] = false; // 백트래킹 + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + int T = Integer.parseInt(br.readLine().trim()); + for(int testCase = 1; testCase <= T; testCase++) { + st = new StringTokenizer(br.readLine().trim()); + ingredientCnt = Integer.parseInt(st.nextToken()); // 재료의 개수 + conditionCnt = Integer.parseInt(st.nextToken()); // 조건의 개수 + + // 초기화 + result = 0; + check = new boolean[ingredientCnt + 1]; + ban = new boolean[ingredientCnt + 1][ingredientCnt + 1]; + while((conditionCnt--)>0){ + st = new StringTokenizer(br.readLine().trim()); + int first = Integer.parseInt(st.nextToken()); // 첫 번째 재료 + int second = Integer.parseInt(st.nextToken()); // 두 번째 재료 + ban[first][second] = true; + ban[second][first] = true; + } + dfs(1); + + sb.append("#").append(testCase).append(" ").append(result).append('\n'); + } + System.out.println(sb.toString()); + } +} From 14dfbe1d4a69c15f2399e058f84f086c014d7f09 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sat, 22 Feb 2025 21:16:29 +0900 Subject: [PATCH 095/177] [SWEA 5215 - 25.02.22] --- ...\352\271\200\354\262\240\355\230\204.java" | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 "SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_\353\266\200\353\266\204\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" diff --git "a/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_\353\266\200\353\266\204\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_\353\266\200\353\266\204\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..e418e15 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_\353\266\200\353\266\204\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,92 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* + * + * 맛 점수 / 칼로리 + * + * 부분집합 + * 1. 재귀 호출 + * 2. 모든 원소를 돌았을 때 기저조건 + * 3. for문으로 전체 원소 탐색하며 visit에 체크된 원소들은 더해서 result값과 비교 + * + * + * */ + +public class SWEA_5215_햄버거다이어트_부분집합_김철현 { + + static int[] tastes; // 인덱스 재료의 맛 + static int[] kcals; // 인덱스 재료의 칼로리 + static boolean[] visit; // 재료를 넣었는지 확인 + + static int ingredientCnt; // 재료 개수 + static int limitKcal; // 제한 칼로리 + + static int result; // 결과값 + // 현재 원소 탐색 nowidx, 칼로리합 sumKcal, 맛 합 sumTaste + static void subSet(int nowidx) + { + // 2. 기저조건 - 모든 원소를 탐색했다면 종료 + if(nowidx == ingredientCnt) + { + int sumKcal=0; + int sumTaste=0; + for(int i = 0; i < kcals.length; i++)//3. for문으로 전체 원소 탐색하며 visit에 체크된 원소들은 더해서 result값과 비교 + { + if(visit[i]) + { + sumKcal += kcals[i]; + sumTaste += tastes[i]; + } + } + if(sumKcal > limitKcal){ + return; + } + else + { + result = Math.max(result, sumTaste); + return; + } + } + + visit[nowidx] = true; + subSet(nowidx + 1); + visit[nowidx] = false; + subSet(nowidx + 1); + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + int T = Integer.parseInt(br.readLine().trim()); + for(int testCase = 1; testCase <= T; testCase++) + { + // 초기화 + result = 0; + // 입력 + st = new StringTokenizer(br.readLine().trim()); + ingredientCnt = Integer.parseInt(st.nextToken()); + limitKcal = Integer.parseInt(st.nextToken()); + + tastes = new int[ingredientCnt]; + kcals = new int[ingredientCnt]; + visit = new boolean[ingredientCnt]; + + for(int input = 0; input < ingredientCnt; input++) + { + st = new StringTokenizer(br.readLine().trim()); + tastes[input] = Integer.parseInt(st.nextToken()); + kcals[input] = Integer.parseInt(st.nextToken()); + } + + // 1. 재귀 호출 + subSet(0); + sb.append("#").append(testCase).append(" ").append(result).append('\n'); + } + System.out.println(sb.toString()); + } +} \ No newline at end of file From a5287307ab3ca9b90604eb5f02f287230c45df29 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sat, 22 Feb 2025 21:50:59 +0900 Subject: [PATCH 096/177] =?UTF-8?q?[2961=20=EB=8F=84=EC=98=81=EC=9D=B4?= =?UTF-8?q?=EA=B0=80=EB=A7=8C=EB=93=A0=EB=A7=9B=EC=9E=88=EB=8A=94=EC=9D=8C?= =?UTF-8?q?=EC=8B=9D=20-=2025.02.22]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BOJ/.idea/.gitignore | 8 +++ ...\352\271\200\354\262\240\355\230\204.java" | 68 +++++++++++++++++++ BOJ/out/production/BOJ/.idea/.gitignore | 8 +++ 3 files changed, 84 insertions(+) create mode 100644 BOJ/.idea/.gitignore create mode 100644 "BOJ/BOJ_2961_\353\217\204\354\230\201\354\235\264\352\260\200\353\247\214\353\223\240\353\247\233\354\236\210\353\212\224\354\235\214\354\213\235_\352\271\200\354\262\240\355\230\204.java" create mode 100644 BOJ/out/production/BOJ/.idea/.gitignore diff --git a/BOJ/.idea/.gitignore b/BOJ/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/BOJ/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/BOJ/BOJ_2961_\353\217\204\354\230\201\354\235\264\352\260\200\353\247\214\353\223\240\353\247\233\354\236\210\353\212\224\354\235\214\354\213\235_\352\271\200\354\262\240\355\230\204.java" "b/BOJ/BOJ_2961_\353\217\204\354\230\201\354\235\264\352\260\200\353\247\214\353\223\240\353\247\233\354\236\210\353\212\224\354\235\214\354\213\235_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..2f4bc0e --- /dev/null +++ "b/BOJ/BOJ_2961_\353\217\204\354\230\201\354\235\264\352\260\200\353\247\214\353\223\240\353\247\233\354\236\210\353\212\224\354\235\214\354\213\235_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,68 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* +* +* 부분조합을 재귀로 호출하여 결과값을 Math.min 으로 구하자 +* 근데 주의해야 할 점이 있음 +* 아무것도 재료를 안넣는건 안됨 +* 그래서 파라미터로 nowCnt 를 넣고 이를 재귀할때 마다 +1 or +0 을 하여 +* 기저조건에서 nowCnt == 0 이라면 값을 갱신하지 않고 리턴하자. +* +* */ + +public class BOJ_2961_도영이가만든맛있는음식_김철현 { + + static int ingredientCnt; + static int[] sour; + static int[] bit; + static boolean[] visit; + static int result = Integer.MAX_VALUE; + + static void subset(int nowidx, int nowCnt){ + if(nowidx == ingredientCnt){ + if(nowCnt == 0) // 재료가 하나도 없으면 리턴 + return; + int sourScore = 1; + int bitScore = 0; + for(int idx = 0; idx < ingredientCnt; idx++){ + if(visit[idx]){ + sourScore *= sour[idx]; + bitScore += bit[idx]; + } + } + result = Math.min(Math.abs(sourScore - bitScore), result); + return; + } + + // 이번 인덱스 넣고 재귀 + visit[nowidx] = true; + subset(nowidx+1, nowCnt+1); + // 이번 인덱스 넣지 않고 제귀 + visit[nowidx] = false; + subset(nowidx + 1, nowCnt); + + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + ingredientCnt = Integer.parseInt(br.readLine().trim()); + + // 초기화 + sour = new int[ingredientCnt]; + bit = new int[ingredientCnt]; + visit = new boolean[ingredientCnt]; + // 입력 + for(int idx = 0; idx < ingredientCnt; idx++) { + st = new StringTokenizer(br.readLine().trim()); + sour[idx] = Integer.parseInt(st.nextToken()); + bit[idx] = Integer.parseInt(st.nextToken()); + } + subset(0, 0); + System.out.println(result); + } +} diff --git a/BOJ/out/production/BOJ/.idea/.gitignore b/BOJ/out/production/BOJ/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/BOJ/out/production/BOJ/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml From 209739af6f5a77a4d9ec496b6f17cbd5ab3f01e9 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sat, 22 Feb 2025 21:51:01 +0900 Subject: [PATCH 097/177] Create BOJ12891.java --- BOJ/BOJ12891.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 BOJ/BOJ12891.java diff --git a/BOJ/BOJ12891.java b/BOJ/BOJ12891.java new file mode 100644 index 0000000..bcbd1f8 --- /dev/null +++ b/BOJ/BOJ12891.java @@ -0,0 +1,16 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ12891 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + st = new StringTokenizer(br.readLine().trim()); + int strlen = Integer.parseInt(st.nextToken()); + int + } +} From 555d180714a3a513af340c50bd5f376a29b5807f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sat, 22 Feb 2025 22:02:30 +0900 Subject: [PATCH 098/177] =?UTF-8?q?[1759=20=EC=95=94=ED=98=B8=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20-=2025.02.22]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ1759/Main.java" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" new file mode 100644 index 0000000..8c065fe --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" @@ -0,0 +1,79 @@ +package BOJ1759; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Arrays; +import java.util.StringTokenizer; + +/* + * 1759 암호만들기 + * 문제 + * 암호는 서로다른 L개의 알파뱃 소문자로 구성된다. + * 1. 1개 이상의 모음 +2개의 자음으로 구성되어 있다. + * 2. 암호는 오름차순이다. + * C개의 문자중에서 골라야한다. + * 풀이 + * 오름차순 = 순서가 중요하지 않음 = 조합 or 부분집합 + * 모음에서 1개이상 고르는 부분 집합 (n개 선택) + * + 자음에서 2개 이상 고르는 부분집합 으로 접근하기 + * + */ +public class Main { + static int L,C,voIndex,conIndex; + static char[] elements; + static char[] selected; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + L = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + selected = new char[L]; + elements = new char[C]; + voIndex= 0; + conIndex=0; + st = new StringTokenizer(br.readLine()); + for(int i = 0; i Date: Sat, 22 Feb 2025 22:36:36 +0900 Subject: [PATCH 099/177] =?UTF-8?q?[14889=20=EC=8A=A4=ED=83=80=ED=8A=B8?= =?UTF-8?q?=EC=99=80=20=EB=A7=81=ED=81=AC=20-=2025.02.02]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ14889/Main.java" | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" new file mode 100644 index 0000000..494d5c5 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" @@ -0,0 +1,76 @@ +package BOJ14889; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* + * 문제 스타트와 링크 + * 축구하자 평일오후 신청자만 + * N명있으니 (짝수) N/2 명씩 팀짠다. + * 능력치 Sij +Sji = i,j가 팀일때 팀에 추가되는능력치 + * 각 팀의 능력치차가 최소가 되도록 팀구성하기 (능력치 차의 최소값) + * 풀이 + * N은 20이라, 2^20 정도만 선택하면 괜찮다. (대략백만?) + * N/2 조합으로 A팀뽑고,나머지들 B팀으로 만든다. + * 차이로 최솟값 갱신해보자 + */ +public class Main { + static int board[][]; + static int minValue = Integer.MAX_VALUE; + static int N; + static int [] teamA,teamB; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + board = new int[N][N]; + teamA = new int[N/2]; + teamB = new int[N/2]; + for(int i = 0; i Date: Sat, 22 Feb 2025 22:40:13 +0900 Subject: [PATCH 100/177] =?UTF-8?q?[14889=20=EC=8A=A4=ED=83=80=ED=8A=B8?= =?UTF-8?q?=EC=99=80=20=EB=A7=81=ED=81=AC=20-=2025.02.22]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" index 494d5c5..b841839 100644 --- "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" @@ -13,7 +13,7 @@ * 풀이 * N은 20이라, 2^20 정도만 선택하면 괜찮다. (대략백만?) * N/2 조합으로 A팀뽑고,나머지들 B팀으로 만든다. - * 차이로 최솟값 갱신해보자 + * 차이로 최솟값 갱신해보자 데헷ㅇㅇㅇㅇ */ public class Main { static int board[][]; @@ -38,7 +38,6 @@ public static void main(String[] args) throws Exception{ } static void dfs(int elementIndex, int indexA,int indexB) { -// System.out.printf("team A : %d, B: %d\n",indexA,indexB); if (indexA == N/2) { for(int i = elementIndex;i Date: Sat, 22 Feb 2025 22:43:16 +0900 Subject: [PATCH 101/177] =?UTF-8?q?[14501=20=ED=87=B4=EC=82=AC=ED=95=98?= =?UTF-8?q?=EA=B3=A0=EC=8B=B6=EB=8B=A4=20-=2025.02.21]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ14501/Main.java" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" index 78adf1d..da2d035 100644 --- "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" @@ -1,6 +1,6 @@ -import java.io.*; -import java.util.Arrays; -import java.util.Comparator; +package BOJ14501; +import java.io.BufferedReader; +import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[][] talk; From ee88094ff39f1f99f50b51a0bc11a44e73d6f72c Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Feb 2025 11:55:13 +0900 Subject: [PATCH 102/177] =?UTF-8?q?[12891=20DNA=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=2025.02.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BOJ/BOJ12891.java | 16 ---- ...\352\271\200\354\262\240\355\230\204.java" | 93 +++++++++++++++++++ 2 files changed, 93 insertions(+), 16 deletions(-) delete mode 100644 BOJ/BOJ12891.java create mode 100644 "BOJ/BOJ_12891_DNA\353\271\204\353\260\200\353\262\210\355\230\270_\352\271\200\354\262\240\355\230\204.java" diff --git a/BOJ/BOJ12891.java b/BOJ/BOJ12891.java deleted file mode 100644 index bcbd1f8..0000000 --- a/BOJ/BOJ12891.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class BOJ12891 { - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - StringBuilder sb = new StringBuilder(); - - st = new StringTokenizer(br.readLine().trim()); - int strlen = Integer.parseInt(st.nextToken()); - int - } -} diff --git "a/BOJ/BOJ_12891_DNA\353\271\204\353\260\200\353\262\210\355\230\270_\352\271\200\354\262\240\355\230\204.java" "b/BOJ/BOJ_12891_DNA\353\271\204\353\260\200\353\262\210\355\230\270_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..5f5d0ac --- /dev/null +++ "b/BOJ/BOJ_12891_DNA\353\271\204\353\260\200\353\262\210\355\230\270_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,93 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* +* +* 슬라이딩 윈도우 +* startidx endidx를 두고 각각을 1씩 증가시키며 현재 각 유효 dna 개수를 카운트한다 +* endidx가 strlen보다 작을동안 반복하며 +* startidx endidx를 각각 1씩 증가시키며 반복 +* startidx - 1 의 원소가 유효 dna 일때는 nowCnt 에서 빼주고 +* endidx의 원소가 유효 dna 일 때는 nowCnt++ 를 해준다. +* +* */ + +public class BOJ_12891_DNA비밀번호_김철현 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + st = new StringTokenizer(br.readLine().trim()); + int strlen = Integer.parseInt(st.nextToken()); + int passlen = Integer.parseInt(st.nextToken()); + String str = br.readLine(); + st = new StringTokenizer(br.readLine().trim()); + // 아래 만큼 각 dna가 필요하다 + int Acnt = Integer.parseInt(st.nextToken()); + int Ccnt = Integer.parseInt(st.nextToken()); + int Gcnt = Integer.parseInt(st.nextToken()); + int Tcnt = Integer.parseInt(st.nextToken()); + // 현재 dna의 개수 + int nowAcnt = 0; + int nowCcnt = 0; + int nowGcnt = 0; + int nowTcnt = 0; + // 슬라이딩 윈도우 + int startIdx = 0; + int endIdx = passlen-1; + // 먼저 현재 윈도우에서의 각 개수를 보기 + for(int idx = startIdx; idx <= endIdx; idx++) { + if(str.charAt(idx) == 'A') { + nowAcnt++; + } + else if(str.charAt(idx) == 'C') { + nowCcnt++; + } + else if(str.charAt(idx) == 'G') { + nowGcnt++; + } + else if(str.charAt(idx) == 'T') { + nowTcnt++; + } + } + int result = 0; + while(endIdx < strlen) + { + // 1. 현재 조건 만족하는지 확인 + if(nowAcnt >= Acnt && nowCcnt >= Ccnt && nowGcnt >= Gcnt && nowTcnt >= Tcnt) { + result++; + } + // 2. startidx 와 endidx를 1씩 증가 + startIdx++; endIdx++; + // 3. 이전 startidx의 원소는 카운트에서 삭제 + if(str.charAt(startIdx - 1) == 'A'){ + nowAcnt--; + } + else if(str.charAt(startIdx - 1) == 'C'){ + nowCcnt--; + } + else if(str.charAt(startIdx - 1) == 'G'){ + nowGcnt--; + } + else if(str.charAt(startIdx - 1) == 'T'){ + nowTcnt--; + } + // 4. endidx원소 카운트 증가 + if (endIdx < strlen) { + if (str.charAt(endIdx) == 'A') { + nowAcnt++; + } else if (str.charAt(endIdx) == 'C') { + nowCcnt++; + } else if (str.charAt(endIdx) == 'G') { + nowGcnt++; + } else if (str.charAt(endIdx) == 'T') { + nowTcnt++; + } + } + } + System.out.println(result); + } +} \ No newline at end of file From ad182e7665c6d608b4e7317909c483a5b5cc1e99 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Feb 2025 11:55:26 +0900 Subject: [PATCH 103/177] =?UTF-8?q?[11723=20=EC=A7=91=ED=95=A9=20-=2025.02?= =?UTF-8?q?.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\271\200\354\262\240\355\230\204.java" | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 "BOJ/BOJ_11723_\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" diff --git "a/BOJ/BOJ_11723_\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" "b/BOJ/BOJ_11723_\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..4f606c9 --- /dev/null +++ "b/BOJ/BOJ_11723_\354\247\221\355\225\251_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,87 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.util.StringTokenizer; + +/* +* +* add +* 1 << x : 0000..00001 을 왼쪽으로 x만큼 쉬프트함 * 2하는 효과 +* |= : or 연산 +* remove +* &= : and 연산 +* ~ : not 연산 +*** 쉬프트해서 not 하면 해당 부분만 0이고 나머지는 1이 될거야 +* 그렇다면 원본에서 삭제하고 싶은 비트는 0으로 없어지겠지 +* +* check +* 1. 쉬프트 연산 하고 +* 2. 원본 set과 비교 +* 3. 해당 값이 1 인지 0 인지로 확인 +* +* toggle +* ^= xor 연산 - 서로 다른 값이어야 1임 +* 원본에 1 이 있으면 같은 1이 들어와서 0 이 되어 없어질거고 +* 원본에 0 이 있으면 다른 1이 들어오서 1 이 될 것임 +* +* all +* 1. 21만큼 쉬프트하고 +* 2. 그거를 -1 해버리면 0111111.....111 이 될 것 +* +* empty 그냥 =0 으로 초기화 +* +* +* */ + +public class BOJ_11723_집합_김철현 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + + int commandCnt = Integer.parseInt(br.readLine()); // 명령어 수 입력 + int set = 0; // 비어있는 공집합 초기화 + + while (commandCnt-- > 0) { + StringTokenizer st = new StringTokenizer(br.readLine()); + String oper = st.nextToken(); // 명령어 읽기 + int x; + + switch (oper) { + case "add": + x = Integer.parseInt(st.nextToken()); + set |= (1 << x); + break; + + case "remove": + x = Integer.parseInt(st.nextToken()); + set &= ~(1 << x); + break; + + case "check": + x = Integer.parseInt(st.nextToken()); + if ((set & (1 << x)) != 0) { + sb.append(1).append("\n"); + } else { + sb.append(0).append("\n"); + } + break; + + case "toggle": + x = Integer.parseInt(st.nextToken()); + set ^= (1 << x); + break; + + case "all": + set = (1 << 21) - 1; // 1~20 비트를 모두 켜기 + break; + + case "empty": + set = 0; // 공집합으로 초기화 + break; + } + } + + // 전체 출력 한 번에 출력 + System.out.print(sb.toString()); + } +} From 88e614edcbda1e13125f2cef9625655baf4c7533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sun, 23 Feb 2025 21:58:37 +0900 Subject: [PATCH 104/177] =?UTF-8?q?[15661=20=EB=A7=81=ED=81=AC=EC=99=80=20?= =?UTF-8?q?=EC=8A=A4=ED=83=80=ED=8A=B8=20-=2025.02.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ15661/Main.java" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" new file mode 100644 index 0000000..ce0385b --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" @@ -0,0 +1,68 @@ +package BOJ15661; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* + * 문제 스타트와 링크 + * 축구하자 평일오후 신청자만 + * N명있다. + * 능력치 Sij +Sji = i,j가 팀일때 팀에 추가되는능력치 + * 각 팀의 능력치차가 최소가 되도록 팀구성하기 (능력치 차의 최소값) + * 풀이 + * N은 20이라, 2^20 정도만 선택하면 괜찮다. (대략백만?) + * A팀 B팀을 따로 선택한다. + * 차이로 최솟값 갱신해보자 + */ +public class Main { + static int board[][]; + static int minValue = Integer.MAX_VALUE; + static int N; + static int [] teamA,teamB; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + board = new int[N+1][N+1]; + teamA = new int[N]; + teamB = new int[N]; + for(int i = 1; i<=N;i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + for(int j=1;j<=N;j++) { + board[i][j] = Integer.parseInt(st.nextToken()); + } + + } + dfs(1,0,0); + System.out.println(minValue); + } + + static void dfs(int elementIndex, int indexA,int indexB) { + + if (indexA+indexB == N) { +// System.out.printf("team A : %s, %d point \nteam B: %s %d point\n", +// Arrays.toString(teamA),getPoint(teamA),Arrays.toString(teamB),getPoint(teamB)); + minValue= Math.min(minValue,Math.abs(getPoint(teamA)-getPoint(teamB))); + return; + } + //A팀으로 영입 + teamA[indexA] = elementIndex; + dfs(elementIndex+1,indexA+1,indexB); + teamA[indexA] = 0; + teamB[indexB] = elementIndex; + dfs(elementIndex+1,indexA,indexB+1); + teamB[indexB] = 0; + } + + static int getPoint(int Team[]) { + int total =0; + for(int i = 0; i Date: Sun, 23 Feb 2025 23:47:25 +0900 Subject: [PATCH 105/177] =?UTF-8?q?[1759=20=EC=95=94=ED=98=B8=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20-=2025.02.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\247\214\353\223\244\352\270\260.java" | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" new file mode 100644 index 0000000..90ccd65 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" @@ -0,0 +1,74 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.util.Arrays; +import java.util.StringTokenizer; +import java.io.InputStreamReader; + +public class BOJ_1759_암호만들기 { + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + static char chars[]; + static int[] nums = new int[8]; + static int isVowel, L, C; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + st = new StringTokenizer(br.readLine()); + L = Integer.parseInt(st.nextToken()); // 암호의 길이 + C = Integer.parseInt(st.nextToken()); // 가능성 있는 문자의 개수 + chars = new char[C]; + + st = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < C; idx++) { + chars[idx] = st.nextToken().charAt(0); + } + Arrays.sort(chars); // 입력받아서 사전순으로 정렬. + + // 비트연산 위해 모음의 인덱스에 1의 값을 넣은 isVowel 초기화 + for (int idx = 0; idx < C; idx++) { + int c = chars[idx]; + if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { + isVowel |= (1 << idx); + } + } + + // 가능한 암호 찾기 + makeSubset(0, 0); + + System.out.println(sb); + + } + + public static void makeSubset(int count, int selectedInfo) { // 현재 고려 요소 idx, 선택된 문자 bitmask + + int selectedCharCount = Integer.bitCount(selectedInfo); + int vowelCount = Integer.bitCount(selectedInfo & isVowel); + + // 선택된 문자의 개수가 암호의 길이와 같은 경우 + if (selectedCharCount == L) { + // 모음의 개수가 1이상, 자음의 개수가 2이상인 경우 + if (vowelCount >= 1 && (selectedCharCount - vowelCount) >= 2) { + // 선택된 문자들 출력 + for (int idx = 0; idx < C; idx++) { + if ((selectedInfo & (1 << idx)) != 0) { + sb.append(chars[idx]); + } + } + sb.append('\n'); + } + + return; + } + + // 모든 요소를 다 고려했을 경우 재귀 호출 종료. + if (count == C) { + return; + } + + // 현재 고려요소 + 1, 현재 요소 선택한 다음 재귀 호출 + makeSubset(count + 1, selectedInfo | (1 << count)); + // 고려요소에 +1 해주고 재귀 호출. + makeSubset(count + 1, selectedInfo); + + } +} From d0490149ac3085c96c9660ccd71f44773b82ee73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Mon, 24 Feb 2025 22:45:56 +0900 Subject: [PATCH 106/177] =?UTF-8?q?[2529=20=EB=B6=80=EB=93=B1=ED=98=B8=20-?= =?UTF-8?q?=2025.02.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ2529/Main.java" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" new file mode 100644 index 0000000..28a8a48 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" @@ -0,0 +1,66 @@ +package BOJ2529; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.StringTokenizer; + +/* + * < 와 > 가 k개 나열된 순서열A + * 부등호 앞뒤에 한자리수 숫자를 넣어서 성립하게 해보세요 + * + */ +public class Main { + static boolean visited[] = new boolean[10]; + static String max = ""; + static String min = ""; + + static int k; + static char c[]; + static int selected[]; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + k = Integer.parseInt(br.readLine()); + c = new char[k]; + selected = new int[k+1]; + StringTokenizer st = new StringTokenizer( br.readLine()); + for(int i= 0; i 0) { + max = num; + } + if (min.isEmpty() || num.compareTo(min) < 0) { + min = num; + } + return; + } + for(int i =0;i<=9;i++) { + if(!visited[i] && (depth==0 + ||(c[depth-1]=='>' && selected[depth-1] > i) + ||(c[depth-1]=='<' && selected[depth-1] < i) + )) { + visited[i]=true; + selected[depth] =i; + dfs(depth+1); + visited[i]=false; + } + } + } +} From 62a28a17cbd4d61eb0c34664ac352512c9f405e5 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Tue, 25 Feb 2025 00:23:01 +0900 Subject: [PATCH 107/177] =?UTF-8?q?[14889=20=EC=8A=A4=ED=83=80=ED=8A=B8?= =?UTF-8?q?=EC=99=80=EB=A7=81=ED=81=AC=20-=2025.02.25]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\231\200\353\247\201\355\201\254.java" | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" new file mode 100644 index 0000000..aa6e5f7 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" @@ -0,0 +1,64 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.util.StringTokenizer; +import java.io.InputStreamReader; + +public class Main { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + static int[][] stats; + static int N, minDiff; + static boolean[] isSelected = new boolean[20]; + + public static void main(String[] args) throws IOException { + + N = Integer.parseInt(br.readLine()); // 총 인원 + stats = new int[N][N]; + + for (int row = 0; row < N; row++) { + st = new StringTokenizer(br.readLine()); + for (int col = 0; col < N; col++) { + stats[row][col] = Integer.parseInt(st.nextToken()); + } + } + + minDiff = Integer.MAX_VALUE; + makeComb(0, 0); + + System.out.println(minDiff); + } + + public static void makeComb(int count, int itemIdx) { + // 한 팀(n/2)를 다 뽑았을 때. + if (count == N / 2) { + int teamAStats = 0, teamBStats = 0; + + // teamA, teamB의 능력치 계산 + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (isSelected[i] && isSelected[j]) { + teamAStats += stats[i][j]; + } + if (!isSelected[i] && !isSelected[j]) { + teamBStats += stats[i][j]; + } + } + } + + minDiff = Math.min(minDiff, Math.abs(teamAStats - teamBStats)); + return; + } + + if (itemIdx == N - 1) { + return; + } + + isSelected[itemIdx] = true; + makeComb(count + 1, itemIdx + 1); + isSelected[itemIdx] = false; + makeComb(count, itemIdx + 1); + + } + +} From fde52ff305f8f73032c995e77206d4c22939f26b Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Tue, 25 Feb 2025 22:26:15 +0900 Subject: [PATCH 108/177] =?UTF-8?q?[15661=20=EB=A7=81=ED=81=AC=EC=99=80?= =?UTF-8?q?=EC=8A=A4=ED=83=80=ED=8A=B8=20-=2025.02.25]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\212\244\355\203\200\355\212\270.java" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" new file mode 100644 index 0000000..bc4630c --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" @@ -0,0 +1,68 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.util.StringTokenizer; +import java.io.InputStreamReader; + +public class BOJ_15661_링크와스타트 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + static int[][] stats; + static int N, minDiff; + static boolean[] isSelected = new boolean[20]; + + public static void main(String[] args) throws IOException { + + N = Integer.parseInt(br.readLine()); // 총 인원 + stats = new int[N][N]; // 능력치 + + // 입력받음 + for (int row = 0; row < N; row++) { + st = new StringTokenizer(br.readLine()); + for (int col = 0; col < N; col++) { + stats[row][col] = Integer.parseInt(st.nextToken()); + } + } + + minDiff = Integer.MAX_VALUE; // 능력치의 차이 최솟값 + makeSubset(0); // 부분집합 계산 + + System.out.println(minDiff); + } + + public static void makeSubset(int count) { + + int teamAStats = 0, teamBStats = 0, teamACount = 0; + // teamA, teamB의 능력치 계산 + for (int i = 0; i < N; i++) { + if (isSelected[i] == true) { + teamACount += 1; // teamA의 인원 계산 + } + for (int j = 0; j < N; j++) { + // stats[][] 전체 순회하면서 둘이 같은 팀일경우 능력치에 더함. + if (isSelected[i] && isSelected[j]) { + teamAStats += stats[i][j]; + } + if (!isSelected[i] && !isSelected[j]) { + teamBStats += stats[i][j]; + } + } + } + + // teamA의 인원이 1명 이상 총인원 미만인 경우만 능력치 최솟값 업데이트 + if (teamACount >= 1 && teamACount < N) { + minDiff = Math.min(minDiff, Math.abs(teamAStats - teamBStats)); + } + + if (count == N - 1) { // 총인원 다 고려했을 때 -> return + return; + } + + isSelected[count] = true; + makeSubset(count + 1); + isSelected[count] = false; + makeSubset(count + 1); + + } + +} From bfcaffe8b42d84802375adf55510aed9eb3eceb9 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Tue, 25 Feb 2025 22:30:05 +0900 Subject: [PATCH 109/177] =?UTF-8?q?[14889=20=EC=8A=A4=ED=83=80=ED=8A=B8?= =?UTF-8?q?=EC=99=80=20=EB=A7=81=ED=81=AC=20-=2025.02.25]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...03\200\355\212\270\354\231\200\353\247\201\355\201\254.java" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" index aa6e5f7..3298695 100644 --- "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" +++ "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" @@ -3,7 +3,7 @@ import java.util.StringTokenizer; import java.io.InputStreamReader; -public class Main { +public class BOJ_14889_스타트와링크 { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringBuilder sb = new StringBuilder(); static StringTokenizer st; From db4bf69d86201911b7c501228c1a9e3849078981 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Tue, 25 Feb 2025 23:16:25 +0900 Subject: [PATCH 110/177] =?UTF-8?q?[2529=20=EB=B6=80=EB=93=B1=ED=98=B8=20-?= =?UTF-8?q?=2025.02.25]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\266\200\353\223\261\355\230\270.java" | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" new file mode 100644 index 0000000..12fe50f --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" @@ -0,0 +1,84 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.util.StringTokenizer; +import java.io.InputStreamReader; + +public class BOJ_2529_부등호 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringBuilder sb = new StringBuilder(); + static StringTokenizer st; + static char[] signs; + static int N, k; + static int[] pArr; + static boolean[] isSelected = new boolean[10]; + static String min = "9999999999", max = "0"; + + public static void main(String[] args) throws IOException { + + k = Integer.parseInt(br.readLine()); // 부등호 개수 + signs = new char[k]; // 부등호 순서 + pArr = new int[k + 1]; // 순열 저장할 배열 + + // 부등호 입력받음 + st = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < k; idx++) { + signs[idx] = st.nextToken().charAt(0); + } + + makePerm(0); + + sb.append(max).append('\n').append(min); + System.out.println(sb); + } + + public static void makePerm(int count) { + + if (count == k + 1) { + boolean flag = true; + // 가능한 순열인지 확인. + for (int idx = 0; idx < k; idx++) { + switch (signs[idx]) { + case '<': + if (pArr[idx] > pArr[idx + 1]) { + flag = false; + } + break; + case '>': + if (pArr[idx] < pArr[idx + 1]) { + flag = false; + } + break; + } + } + + // 가능한 순열이면 + if (flag == true) { + StringBuilder sb = new StringBuilder(); + for (int num : pArr) { + sb.append(num); + } + String numStr = sb.toString(); + + if (numStr.compareTo(min) < 0) { + min = numStr; + } + if (numStr.compareTo(max) > 0) { + max = numStr; + } + } + return; + } + + for (int idx = 0; idx <= 9; idx++) { + if (isSelected[idx] == false) { + isSelected[idx] = true; + pArr[count] = idx; + makePerm(count + 1); + isSelected[idx] = false; + } + } + + } + +} \ No newline at end of file From aa208f3bcc1d5590e0d039e7d1aebb4171913fc0 Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 15:10:05 +0900 Subject: [PATCH 111/177] =?UTF-8?q?[10026=20=EC=A0=81=EB=A1=9D=EC=83=89?= =?UTF-8?q?=EC=95=BD=20-=2025.03.07]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\271\200\354\262\240\355\230\204.java" | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 "BOJ/BOJ_10026_\354\240\201\353\241\235\354\203\211\354\225\275_\352\271\200\354\262\240\355\230\204.java" diff --git "a/BOJ/BOJ_10026_\354\240\201\353\241\235\354\203\211\354\225\275_\352\271\200\354\262\240\355\230\204.java" "b/BOJ/BOJ_10026_\354\240\201\353\241\235\354\203\211\354\225\275_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..fca3cd7 --- /dev/null +++ "b/BOJ/BOJ_10026_\354\240\201\353\241\235\354\203\211\354\225\275_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,160 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.Queue; +import java.util.StringTokenizer; + +/* + * + * bfs 호출 시 마다 결과 값을 1씩 증가시킨다. + * + 색맹 전용의 bfs 와 + 일반인 전용의 bfs를 둔다 . + + 1. 일반인 전용의 bfs는 알파벳이 같아야만 하나의 덩어리로 본다. + 2. 색맹 전용의 bfs는 알파벳이 R과 G가 같아도 하나의 덩어리로 보아야 하기 때문에 + 이 부분만 주의해서 큐에 넣기 + * */ + +public class BOJ_10026_적록색약_김철현 { + + static int size; + static char[][] map; + static boolean[][] visit; + + static int[] dirR = {1,-1,0,0}; + static int[] dirC = {0,0,1,-1}; + + static class Pair{ + + int row; + int col; + + public Pair(int row, int col) { + this.row = row; + this.col = col; + } + } + + // 일반인 전용의 bfs + static void bfs_ord(int startR, int startC) { + char thisColor = map[startR][startC]; + + Queue q = new LinkedList<>(); + visit[startR][startC] = true; + q.add(new Pair(startR, startC)); + while(!q.isEmpty()) + { + Pair now = q.poll(); + int nowR = now.row; + int nowC = now.col; + for(int dir=0;dir<4;dir++) { + int nextR = nowR + dirR[dir]; + int nextC = nowC + dirC[dir]; + // 범위 체크 + if(nextR < 0 || nextC < 0 || nextR >=size || nextC >= size) { + continue; + } + // 방문 체크 + if(visit[nextR][nextC]) + continue; + // 알파벳 체크 + if(thisColor == map[nextR][nextC]) + { + visit[nextR][nextC] = true; + q.add(new Pair(nextR, nextC)); + } + } + } + } + + // 색맹 전용의 Bfs + static void bfs_inord(int startR, int startC) { + char thisColor = map[startR][startC]; + + Queue q = new LinkedList<>(); + visit[startR][startC] = true; + q.add(new Pair(startR, startC)); + while(!q.isEmpty()) + { + Pair now = q.poll(); + int nowR = now.row; + int nowC = now.col; + for(int dir=0;dir<4;dir++) { + int nextR = nowR + dirR[dir]; + int nextC = nowC + dirC[dir]; + // 범위 체크 + if(nextR < 0 || nextC < 0 || nextR >=size || nextC >= size) { + continue; + } + // 방문 체크 + if(visit[nextR][nextC]) + continue; + // 알파벳 체크 + if((thisColor == 'R' || thisColor == 'G')&&(map[nextR][nextC] == 'R'||map[nextR][nextC] == 'G')) + { + visit[nextR][nextC] = true; + q.add(new Pair(nextR, nextC)); + } + else if(thisColor == 'B'&&map[nextR][nextC] == 'B') + { + visit[nextR][nextC] = true; + q.add(new Pair(nextR, nextC)); + } + } + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + // 알고리즘 시작 + st = new StringTokenizer(br.readLine().trim()); + size = Integer.parseInt(st.nextToken()); + map = new char[size][size]; + visit = new boolean[size][size]; + // 맵 입력 + for(int row = 0 ; row < size; row++) { + String str = br.readLine().trim(); + for(int col = 0; col < size; col++) { + map[row][col] = str.charAt(col); + } + } + + // 일반 처리 + int result_ord = 0; + for(int row = 0 ; row < size; row++) { + for(int col = 0; col < size; col++) { + if(visit[row][col] == false) + { + bfs_ord(row, col); + result_ord++; + } + } + } + // 방문 복구 + for(int row = 0 ; row < size; row++) { + for(int col = 0; col < size; col++) { + visit[row][col] = false; + } + } + // 색약처리 + int result_inord = 0; + for(int row = 0 ; row < size; row++) { + for(int col = 0; col < size; col++) { + if(visit[row][col] == false) + { + bfs_inord(row, col); + result_inord++; + } + } + } + + sb.append(result_ord).append(" ").append(result_inord); + System.out.println(sb.toString()); + } +} \ No newline at end of file From dae0acfca24c64cf40b7dca70b34bfc0bb1a630a Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 15:23:48 +0900 Subject: [PATCH 112/177] =?UTF-8?q?2=EC=9B=94=202=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 ----- .../ChulHyeon/.idea/.gitignore" | 8 -- ...\352\271\200\354\262\240\355\230\204.java" | 63 ---------- .../ChulHyeon/src/BOJ1759/Main.java" | 25 ---- ...\352\271\200\354\262\240\355\230\204.java" | 97 +++++++++++++++ ...\352\271\200\354\262\240\355\230\204.java" | 45 +++++++ ...\352\271\200\354\262\240\355\230\204.java" | 117 ++++++++++++++++++ 7 files changed, 259 insertions(+), 125 deletions(-) delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" create mode 100644 "BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" create mode 100644 "SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" create mode 100644 "SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" deleted file mode 100644 index f68d109..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" +++ /dev/null @@ -1,29 +0,0 @@ -### IntelliJ IDEA ### -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" deleted file mode 100644 index c3f502a..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" +++ /dev/null @@ -1,8 +0,0 @@ -# 디폴트 무시된 파일 -/shelf/ -/workspace.xml -# 에디터 기반 HTTP 클라이언트 요청 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" deleted file mode 100644 index fbda4a6..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" +++ /dev/null @@ -1,63 +0,0 @@ -package BOJ11660; - -/* -* -* mapSize / testCase 입력 -* map 입력 -* testCase 입력 -* -* 부분합을 사용해야 하므로 2차원 배열 0은 냅두고 1부터 시작하는것을 map으로 한다. -* 1. map 을 입력 받는다. -* 2. sum 2차원 배열을 두고 1행 가로열을 채운다 -* 3. 1열 세로열을 채운다 -* 4. 2 2 3 4 로 입력이 들어왔다면 sum[3][4] - sum[2][2] 가 정답! -* -* */ - - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class BOJ_11660_구간합구하기5_김철현 { - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringBuilder sb = new StringBuilder(); - StringTokenizer st; - - st = new StringTokenizer(br.readLine()); - int mapSize= Integer.parseInt(st.nextToken()); // 맵의 크기 - int testCase = Integer.parseInt(st.nextToken()); // 테스트케이스 개수 - - int map[][] = new int[mapSize + 1][mapSize + 1]; // 맵 - int sum[][] = new int[mapSize + 1][mapSize + 1]; // 누적합 배열 - - // 1. 맵 입력 - for(int row = 1; row <= mapSize; row++) { - st= new StringTokenizer(br.readLine()); - for(int col = 1; col <= mapSize; col++) { - map[row][col] = Integer.parseInt(st.nextToken()); - } - } - // 4. 누적합 계산 - for(int row = 1; row <= mapSize; row++) { - for(int col = 1; col <= mapSize; col++) { - sum[row][col] = map[row][col] + sum[row - 1][col] + sum[row][col - 1] - sum[row-1][col-1]; - } - } - // 5. 테케 만큼 구해서 출력 - while((testCase--) > 0) - { - st = new StringTokenizer(br.readLine()); - int firstR = Integer.parseInt(st.nextToken()); - int firstC = Integer.parseInt(st.nextToken()); - int secondR = Integer.parseInt(st.nextToken()); - int secondC = Integer.parseInt(st.nextToken()); - // 누적합 출력 이 때 내 기준 위에 줄 싹, 왼쪽 줄 싹 빼주고 11시방향 대각선 부분은 2번 빼준 거므로 한번 더해준다. - sb.append(sum[secondR][secondC] - sum[firstR - 1][secondC] - sum[secondR][firstC-1] - + sum[firstR-1][firstC-1]).append('\n'); - } - System.out.println(sb.toString()); - } -} diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" deleted file mode 100644 index 6527c7f..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" +++ /dev/null @@ -1,25 +0,0 @@ -package BOJ1759; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class Main { - static int L; - static int C; - static char[] arr; - - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - StringBuilder sb = new StringBuilder(); - st = new StringTokenizer(br.readLine()); - L = Integer.parseInt(st.nextToken()); - C = Integer.parseInt(st.nextToken()); - arr = new char[L]; - for (int i = 0; i < L; i++) { - - } - } -} diff --git "a/BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" "b/BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..de3e547 --- /dev/null +++ "b/BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,97 @@ +/* +5 0 0 3 0 2 2 0 3 0 0 5 4 0 1 1 0 4 +4 1 0 3 0 2 4 1 0 1 1 3 0 0 5 1 1 3 +5 0 0 4 0 1 2 2 1 2 0 3 1 0 4 0 0 5 +5 0 0 3 1 1 2 1 2 2 0 3 0 0 5 1 0 4 + +1. 재귀 인자로 팀A 인덱스, 팀B 인덱스를 넣는다. + 1-1. 팀A가 6까지 갔다는건 다 돌았다는 것 + 1-2. 팀B가 6까지 갔다는건 팀A와 매칭할 수 있는 경우의 수를 돌았다는 것 +2. 각 경우의 수를 보며 어느 한쪽이 승이고 어느 한쪽이 패 일때 가지고 있는 가능 승/패의 영이 1 이상이면 재귀 호출 + 2-1. 원상복구 꼭 해줘야 함 + +* */ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_6987_월드컵_김철현 { + static int[][] countries = new int[6][3]; + static boolean isValid; + + static void dfs(int teamA, int teamB) { + // 모든 경기(15경기)를 다 확인했으면 검증 완료 + if (teamA == 6) { + isValid = true; + return; + } + + // 다음 경기 팀 설정 (teamB 증가) + if (teamB == 6) { + dfs(teamA + 1, teamA + 2); // 다음 국가로 넘어감 + return; + } + + // A가 승, B가 패 + if (countries[teamA][0] > 0 && countries[teamB][2] > 0) { + countries[teamA][0]--; + countries[teamB][2]--; + dfs(teamA, teamB + 1); + countries[teamA][0]++; + countries[teamB][2]++; + } + + // A와 B가 무승부 + if (countries[teamA][1] > 0 && countries[teamB][1] > 0) { + countries[teamA][1]--; + countries[teamB][1]--; + dfs(teamA, teamB + 1); + countries[teamA][1]++; + countries[teamB][1]++; + } + + // B가 승, A가 패 + if (countries[teamA][2] > 0 && countries[teamB][0] > 0) { + countries[teamA][2]--; + countries[teamB][0]--; + dfs(teamA, teamB + 1); + countries[teamA][2]++; + countries[teamB][0]++; + } + } + + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + // 입력 + for(int testCase = 1; testCase <=4; testCase++) { + st = new StringTokenizer(br.readLine()); + int country = 0; + int winDrawLose = 0; + int totalScore = 0; + isValid = false; + for(int idx = 0; idx < 18; idx++) { + country = idx / 3; + winDrawLose = idx % 3; + int score = Integer.parseInt(st.nextToken()); + countries[country][winDrawLose] = score; + if(score > 0) totalScore += score; + } + + dfs(0, 1); + if(totalScore != 30) + isValid = false; + if(isValid) + sb.append(1).append(" "); + else + sb.append(0).append(" "); + } + System.out.println(sb.toString().trim()); + + + } +} diff --git "a/SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..917d2b5 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,45 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.LinkedList; +import java.util.Queue; +import java.util.StringTokenizer; + +public class SWEA_1225_암호생성기_김철현 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + for(int testCase = 1; testCase <= 10; testCase++) { + // 첫번째 쓰레기값 버리기 + br.readLine(); + Queue queue = new LinkedList<>(); + st = new StringTokenizer(br.readLine().trim()); + for(int idx = 0;idx<8;idx++) { + queue.add(Integer.parseInt(st.nextToken())); + } + int minus = 1; + while(true){ + int front = queue.poll(); + front = front - minus; + if(front <= 0 ) + { + queue.add(0); + break; + } + queue.add(front); + minus = (minus + 1); + if(minus == 6) + minus = 1; + + } + sb.append("#").append(testCase).append(" "); + for(int element : queue){ + sb.append(element).append(" "); + } + sb.append("\n"); + } + System.out.print(sb.toString()); + } +} diff --git "a/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..208eb34 --- /dev/null +++ "b/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,117 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +/* +* +* 000....1111 이런 배열을 하나 두고 1인 부분에 해당하는 재료만 선택하는 코드 +* 1. 1의 개수는 1부터 모든 재료의 개수만큼 선택할 수 있도록 반복문을 돌린다. +* +* 2. 1의 개수가 정해졌다면 해당 배열에 대해 전체 순열을 구한다. +* 3. 전체 순열을 구했다면 해당 순열의 1에 해당하는 재료를 모두 더해준다. +* 4. limit보다 작다면 result값을 갱신해서 결과를 구한다. +* +* */ + +public class SWEA_5215_햄버거다이어트_NextPermutation_김철현 { + + static int[] tastes; // 재료의 맛 점수 + static int[] kcals; // 재료의 칼로리 + static int ingredientCnt; // 재료 개수 + static int limitKcal; // 제한 칼로리 + static int result; // 결과값 + + // 다음 순열 생성 함수 + static boolean nextPermutation(int[] select) { + int i = select.length - 1; + while (i > 0 && select[i - 1] >= select[i]) { + i--; + } + if (i == 0) return false; // 다음 순열이 없다는 것 + + // i-1 과 교환할 조금 더 큰 j 찾기 + int j = select.length - 1; + while (select[i - 1] >= select[j]) { + j--; + } + + // i-1 / j 교환 + int temp = select[i - 1]; + select[i - 1] = select[j]; + select[j] = temp; + + // i 부터 끝 까지 오름차순으로 변환 + j = select.length - 1; + while (i < j) { + temp = select[i]; + select[i] = select[j]; + select[j] = temp; + i++; + j--; + } + return true; + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + int T = Integer.parseInt(br.readLine().trim()); // 테스트 케이스 수 + + for (int testCase = 1; testCase <= T; testCase++) { + // 초기화 + result = 0; + + // 입력 + st = new StringTokenizer(br.readLine().trim()); + ingredientCnt = Integer.parseInt(st.nextToken()); + limitKcal = Integer.parseInt(st.nextToken()); + + tastes = new int[ingredientCnt]; + kcals = new int[ingredientCnt]; + + for (int i = 0; i < ingredientCnt; i++) { + st = new StringTokenizer(br.readLine().trim()); + tastes[i] = Integer.parseInt(st.nextToken()); + kcals[i] = Integer.parseInt(st.nextToken()); + } + + // 1개만 고를래 ? 2개 고를래? 아니면 다 고를래? + for (int selectCnt = 1; selectCnt <= ingredientCnt; selectCnt++) { + int[] select = new int[ingredientCnt]; + + // selectCnt개를 만큼 1로 둠 + for (int i = ingredientCnt - selectCnt; i < ingredientCnt; i++) { + select[i] = 1; + } + + // 모든 순열 확인 + do { + int sumTaste = 0; + int sumKcal = 0; + + // 현재 순열에 따라 1인 부분에 한해서 맛 점수와 칼로리 합 계산 + for (int i = 0; i < ingredientCnt; i++) { + if (select[i] == 1) { + sumTaste += tastes[i]; + sumKcal += kcals[i]; + } + } + // 제한 칼로리 이하인 경우, result 갱신 + if (sumKcal <= limitKcal) { + result = Math.max(result, sumTaste); + } + + } while (nextPermutation(select)); + } + + // 출력 + sb.append("#").append(testCase).append(" ").append(result).append('\n'); + } + + // 출력 + System.out.println(sb.toString()); + } +} From 5ca3ac8b6f3b6f7a8e0a19eba31c0edf5a36bfaf Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 15:25:57 +0900 Subject: [PATCH 113/177] =?UTF-8?q?Revert=20"2=EC=9B=94=202=EC=A3=BC?= =?UTF-8?q?=EC=B0=A8=20=EC=82=AD=EC=A0=9C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dae0acfca24c64cf40b7dca70b34bfc0bb1a630a. --- .../ChulHyeon/.gitignore" | 29 +++++ .../ChulHyeon/.idea/.gitignore" | 8 ++ ...\352\271\200\354\262\240\355\230\204.java" | 63 ++++++++++ .../ChulHyeon/src/BOJ1759/Main.java" | 25 ++++ ...\352\271\200\354\262\240\355\230\204.java" | 97 --------------- ...\352\271\200\354\262\240\355\230\204.java" | 45 ------- ...\352\271\200\354\262\240\355\230\204.java" | 117 ------------------ 7 files changed, 125 insertions(+), 259 deletions(-) create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" create mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" delete mode 100644 "BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" delete mode 100644 "SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" delete mode 100644 "SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" new file mode 100644 index 0000000..fbda4a6 --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" @@ -0,0 +1,63 @@ +package BOJ11660; + +/* +* +* mapSize / testCase 입력 +* map 입력 +* testCase 입력 +* +* 부분합을 사용해야 하므로 2차원 배열 0은 냅두고 1부터 시작하는것을 map으로 한다. +* 1. map 을 입력 받는다. +* 2. sum 2차원 배열을 두고 1행 가로열을 채운다 +* 3. 1열 세로열을 채운다 +* 4. 2 2 3 4 로 입력이 들어왔다면 sum[3][4] - sum[2][2] 가 정답! +* +* */ + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_11660_구간합구하기5_김철현 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + + st = new StringTokenizer(br.readLine()); + int mapSize= Integer.parseInt(st.nextToken()); // 맵의 크기 + int testCase = Integer.parseInt(st.nextToken()); // 테스트케이스 개수 + + int map[][] = new int[mapSize + 1][mapSize + 1]; // 맵 + int sum[][] = new int[mapSize + 1][mapSize + 1]; // 누적합 배열 + + // 1. 맵 입력 + for(int row = 1; row <= mapSize; row++) { + st= new StringTokenizer(br.readLine()); + for(int col = 1; col <= mapSize; col++) { + map[row][col] = Integer.parseInt(st.nextToken()); + } + } + // 4. 누적합 계산 + for(int row = 1; row <= mapSize; row++) { + for(int col = 1; col <= mapSize; col++) { + sum[row][col] = map[row][col] + sum[row - 1][col] + sum[row][col - 1] - sum[row-1][col-1]; + } + } + // 5. 테케 만큼 구해서 출력 + while((testCase--) > 0) + { + st = new StringTokenizer(br.readLine()); + int firstR = Integer.parseInt(st.nextToken()); + int firstC = Integer.parseInt(st.nextToken()); + int secondR = Integer.parseInt(st.nextToken()); + int secondC = Integer.parseInt(st.nextToken()); + // 누적합 출력 이 때 내 기준 위에 줄 싹, 왼쪽 줄 싹 빼주고 11시방향 대각선 부분은 2번 빼준 거므로 한번 더해준다. + sb.append(sum[secondR][secondC] - sum[firstR - 1][secondC] - sum[secondR][firstC-1] + + sum[firstR-1][firstC-1]).append('\n'); + } + System.out.println(sb.toString()); + } +} diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" new file mode 100644 index 0000000..6527c7f --- /dev/null +++ "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" @@ -0,0 +1,25 @@ +package BOJ1759; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int L; + static int C; + static char[] arr; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + st = new StringTokenizer(br.readLine()); + L = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + arr = new char[L]; + for (int i = 0; i < L; i++) { + + } + } +} diff --git "a/BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" "b/BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" deleted file mode 100644 index de3e547..0000000 --- "a/BOJ/BOJ_6987_\354\233\224\353\223\234\354\273\265_\352\271\200\354\262\240\355\230\204.java" +++ /dev/null @@ -1,97 +0,0 @@ -/* -5 0 0 3 0 2 2 0 3 0 0 5 4 0 1 1 0 4 -4 1 0 3 0 2 4 1 0 1 1 3 0 0 5 1 1 3 -5 0 0 4 0 1 2 2 1 2 0 3 1 0 4 0 0 5 -5 0 0 3 1 1 2 1 2 2 0 3 0 0 5 1 0 4 - -1. 재귀 인자로 팀A 인덱스, 팀B 인덱스를 넣는다. - 1-1. 팀A가 6까지 갔다는건 다 돌았다는 것 - 1-2. 팀B가 6까지 갔다는건 팀A와 매칭할 수 있는 경우의 수를 돌았다는 것 -2. 각 경우의 수를 보며 어느 한쪽이 승이고 어느 한쪽이 패 일때 가지고 있는 가능 승/패의 영이 1 이상이면 재귀 호출 - 2-1. 원상복구 꼭 해줘야 함 - -* */ - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class BOJ_6987_월드컵_김철현 { - static int[][] countries = new int[6][3]; - static boolean isValid; - - static void dfs(int teamA, int teamB) { - // 모든 경기(15경기)를 다 확인했으면 검증 완료 - if (teamA == 6) { - isValid = true; - return; - } - - // 다음 경기 팀 설정 (teamB 증가) - if (teamB == 6) { - dfs(teamA + 1, teamA + 2); // 다음 국가로 넘어감 - return; - } - - // A가 승, B가 패 - if (countries[teamA][0] > 0 && countries[teamB][2] > 0) { - countries[teamA][0]--; - countries[teamB][2]--; - dfs(teamA, teamB + 1); - countries[teamA][0]++; - countries[teamB][2]++; - } - - // A와 B가 무승부 - if (countries[teamA][1] > 0 && countries[teamB][1] > 0) { - countries[teamA][1]--; - countries[teamB][1]--; - dfs(teamA, teamB + 1); - countries[teamA][1]++; - countries[teamB][1]++; - } - - // B가 승, A가 패 - if (countries[teamA][2] > 0 && countries[teamB][0] > 0) { - countries[teamA][2]--; - countries[teamB][0]--; - dfs(teamA, teamB + 1); - countries[teamA][2]++; - countries[teamB][0]++; - } - } - - - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - StringBuilder sb = new StringBuilder(); - // 입력 - for(int testCase = 1; testCase <=4; testCase++) { - st = new StringTokenizer(br.readLine()); - int country = 0; - int winDrawLose = 0; - int totalScore = 0; - isValid = false; - for(int idx = 0; idx < 18; idx++) { - country = idx / 3; - winDrawLose = idx % 3; - int score = Integer.parseInt(st.nextToken()); - countries[country][winDrawLose] = score; - if(score > 0) totalScore += score; - } - - dfs(0, 1); - if(totalScore != 30) - isValid = false; - if(isValid) - sb.append(1).append(" "); - else - sb.append(0).append(" "); - } - System.out.println(sb.toString().trim()); - - - } -} diff --git "a/SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" deleted file mode 100644 index 917d2b5..0000000 --- "a/SWEA/ChulHyeon/SWEA_1225_\354\225\224\355\230\270\354\203\235\354\204\261\352\270\260_\352\271\200\354\262\240\355\230\204.java" +++ /dev/null @@ -1,45 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.LinkedList; -import java.util.Queue; -import java.util.StringTokenizer; - -public class SWEA_1225_암호생성기_김철현 { - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - StringBuilder sb = new StringBuilder(); - - for(int testCase = 1; testCase <= 10; testCase++) { - // 첫번째 쓰레기값 버리기 - br.readLine(); - Queue queue = new LinkedList<>(); - st = new StringTokenizer(br.readLine().trim()); - for(int idx = 0;idx<8;idx++) { - queue.add(Integer.parseInt(st.nextToken())); - } - int minus = 1; - while(true){ - int front = queue.poll(); - front = front - minus; - if(front <= 0 ) - { - queue.add(0); - break; - } - queue.add(front); - minus = (minus + 1); - if(minus == 6) - minus = 1; - - } - sb.append("#").append(testCase).append(" "); - for(int element : queue){ - sb.append(element).append(" "); - } - sb.append("\n"); - } - System.out.print(sb.toString()); - } -} diff --git "a/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" "b/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" deleted file mode 100644 index 208eb34..0000000 --- "a/SWEA/ChulHyeon/SWEA_5215_\355\226\204\353\262\204\352\261\260\353\213\244\354\235\264\354\226\264\355\212\270_NextPermutation_\352\271\200\354\262\240\355\230\204.java" +++ /dev/null @@ -1,117 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -/* -* -* 000....1111 이런 배열을 하나 두고 1인 부분에 해당하는 재료만 선택하는 코드 -* 1. 1의 개수는 1부터 모든 재료의 개수만큼 선택할 수 있도록 반복문을 돌린다. -* -* 2. 1의 개수가 정해졌다면 해당 배열에 대해 전체 순열을 구한다. -* 3. 전체 순열을 구했다면 해당 순열의 1에 해당하는 재료를 모두 더해준다. -* 4. limit보다 작다면 result값을 갱신해서 결과를 구한다. -* -* */ - -public class SWEA_5215_햄버거다이어트_NextPermutation_김철현 { - - static int[] tastes; // 재료의 맛 점수 - static int[] kcals; // 재료의 칼로리 - static int ingredientCnt; // 재료 개수 - static int limitKcal; // 제한 칼로리 - static int result; // 결과값 - - // 다음 순열 생성 함수 - static boolean nextPermutation(int[] select) { - int i = select.length - 1; - while (i > 0 && select[i - 1] >= select[i]) { - i--; - } - if (i == 0) return false; // 다음 순열이 없다는 것 - - // i-1 과 교환할 조금 더 큰 j 찾기 - int j = select.length - 1; - while (select[i - 1] >= select[j]) { - j--; - } - - // i-1 / j 교환 - int temp = select[i - 1]; - select[i - 1] = select[j]; - select[j] = temp; - - // i 부터 끝 까지 오름차순으로 변환 - j = select.length - 1; - while (i < j) { - temp = select[i]; - select[i] = select[j]; - select[j] = temp; - i++; - j--; - } - return true; - } - - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringBuilder sb = new StringBuilder(); - StringTokenizer st; - - int T = Integer.parseInt(br.readLine().trim()); // 테스트 케이스 수 - - for (int testCase = 1; testCase <= T; testCase++) { - // 초기화 - result = 0; - - // 입력 - st = new StringTokenizer(br.readLine().trim()); - ingredientCnt = Integer.parseInt(st.nextToken()); - limitKcal = Integer.parseInt(st.nextToken()); - - tastes = new int[ingredientCnt]; - kcals = new int[ingredientCnt]; - - for (int i = 0; i < ingredientCnt; i++) { - st = new StringTokenizer(br.readLine().trim()); - tastes[i] = Integer.parseInt(st.nextToken()); - kcals[i] = Integer.parseInt(st.nextToken()); - } - - // 1개만 고를래 ? 2개 고를래? 아니면 다 고를래? - for (int selectCnt = 1; selectCnt <= ingredientCnt; selectCnt++) { - int[] select = new int[ingredientCnt]; - - // selectCnt개를 만큼 1로 둠 - for (int i = ingredientCnt - selectCnt; i < ingredientCnt; i++) { - select[i] = 1; - } - - // 모든 순열 확인 - do { - int sumTaste = 0; - int sumKcal = 0; - - // 현재 순열에 따라 1인 부분에 한해서 맛 점수와 칼로리 합 계산 - for (int i = 0; i < ingredientCnt; i++) { - if (select[i] == 1) { - sumTaste += tastes[i]; - sumKcal += kcals[i]; - } - } - // 제한 칼로리 이하인 경우, result 갱신 - if (sumKcal <= limitKcal) { - result = Math.max(result, sumTaste); - } - - } while (nextPermutation(select)); - } - - // 출력 - sb.append("#").append(testCase).append(" ").append(result).append('\n'); - } - - // 출력 - System.out.println(sb.toString()); - } -} From bb24317cf7f96883a41b37557b49a1e2f5fdcac4 Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 15:26:37 +0900 Subject: [PATCH 114/177] =?UTF-8?q?2=EC=9B=94=202=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 --------- .../ChulHyeon/.idea/.gitignore" | 8 --- ...\352\271\200\354\262\240\355\230\204.java" | 63 ------------------- .../ChulHyeon/src/BOJ1759/Main.java" | 25 -------- 4 files changed, 125 deletions(-) delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" delete mode 100644 "2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" deleted file mode 100644 index f68d109..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.gitignore" +++ /dev/null @@ -1,29 +0,0 @@ -### IntelliJ IDEA ### -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" deleted file mode 100644 index c3f502a..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" +++ /dev/null @@ -1,8 +0,0 @@ -# 디폴트 무시된 파일 -/shelf/ -/workspace.xml -# 에디터 기반 HTTP 클라이언트 요청 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" deleted file mode 100644 index fbda4a6..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ11660/BOJ_11660_\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605_\352\271\200\354\262\240\355\230\204.java" +++ /dev/null @@ -1,63 +0,0 @@ -package BOJ11660; - -/* -* -* mapSize / testCase 입력 -* map 입력 -* testCase 입력 -* -* 부분합을 사용해야 하므로 2차원 배열 0은 냅두고 1부터 시작하는것을 map으로 한다. -* 1. map 을 입력 받는다. -* 2. sum 2차원 배열을 두고 1행 가로열을 채운다 -* 3. 1열 세로열을 채운다 -* 4. 2 2 3 4 로 입력이 들어왔다면 sum[3][4] - sum[2][2] 가 정답! -* -* */ - - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class BOJ_11660_구간합구하기5_김철현 { - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringBuilder sb = new StringBuilder(); - StringTokenizer st; - - st = new StringTokenizer(br.readLine()); - int mapSize= Integer.parseInt(st.nextToken()); // 맵의 크기 - int testCase = Integer.parseInt(st.nextToken()); // 테스트케이스 개수 - - int map[][] = new int[mapSize + 1][mapSize + 1]; // 맵 - int sum[][] = new int[mapSize + 1][mapSize + 1]; // 누적합 배열 - - // 1. 맵 입력 - for(int row = 1; row <= mapSize; row++) { - st= new StringTokenizer(br.readLine()); - for(int col = 1; col <= mapSize; col++) { - map[row][col] = Integer.parseInt(st.nextToken()); - } - } - // 4. 누적합 계산 - for(int row = 1; row <= mapSize; row++) { - for(int col = 1; col <= mapSize; col++) { - sum[row][col] = map[row][col] + sum[row - 1][col] + sum[row][col - 1] - sum[row-1][col-1]; - } - } - // 5. 테케 만큼 구해서 출력 - while((testCase--) > 0) - { - st = new StringTokenizer(br.readLine()); - int firstR = Integer.parseInt(st.nextToken()); - int firstC = Integer.parseInt(st.nextToken()); - int secondR = Integer.parseInt(st.nextToken()); - int secondC = Integer.parseInt(st.nextToken()); - // 누적합 출력 이 때 내 기준 위에 줄 싹, 왼쪽 줄 싹 빼주고 11시방향 대각선 부분은 2번 빼준 거므로 한번 더해준다. - sb.append(sum[secondR][secondC] - sum[firstR - 1][secondC] - sum[secondR][firstC-1] - + sum[firstR-1][firstC-1]).append('\n'); - } - System.out.println(sb.toString()); - } -} diff --git "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" "b/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" deleted file mode 100644 index 6527c7f..0000000 --- "a/2\354\233\224 3\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" +++ /dev/null @@ -1,25 +0,0 @@ -package BOJ1759; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class Main { - static int L; - static int C; - static char[] arr; - - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - StringBuilder sb = new StringBuilder(); - st = new StringTokenizer(br.readLine()); - L = Integer.parseInt(st.nextToken()); - C = Integer.parseInt(st.nextToken()); - arr = new char[L]; - for (int i = 0; i < L; i++) { - - } - } -} From a6f6f097374057b60f5b5373340db733b37b5a7b Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 16:39:08 +0900 Subject: [PATCH 115/177] =?UTF-8?q?3=EC=9B=94=202=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=ED=8F=B4=EB=8D=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 +++++++++++++++++++ .../ChulHyeon/.idea/.gitignore" | 8 +++++ .../ChulHyeon/src/Main.java" | 5 ++++ 3 files changed, 42 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" new file mode 100644 index 0000000..d5238c9 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} \ No newline at end of file From 07c70b979d0711634563e054a4710c34f52afebb Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 16:45:31 +0900 Subject: [PATCH 116/177] =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- out/production/SSAFY-AlgorithmStudy/.idea/.gitignore | 8 -------- .../out/production/ChulHyeon/.idea/.gitignore | 8 -------- 2 files changed, 16 deletions(-) delete mode 100644 out/production/SSAFY-AlgorithmStudy/.idea/.gitignore delete mode 100644 out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore diff --git a/out/production/SSAFY-AlgorithmStudy/.idea/.gitignore b/out/production/SSAFY-AlgorithmStudy/.idea/.gitignore deleted file mode 100644 index c3f502a..0000000 --- a/out/production/SSAFY-AlgorithmStudy/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 디폴트 무시된 파일 -/shelf/ -/workspace.xml -# 에디터 기반 HTTP 클라이언트 요청 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore b/out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore deleted file mode 100644 index 96839f3..0000000 --- a/out/production/SSAFY-AlgorithmStudy/out/production/ChulHyeon/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 디폴트 무시된 파일 -/shelf/ -/workspace.xml -# 에디터 기반 HTTP 클라이언트 요청 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml \ No newline at end of file From c0d3bc8dae3a5d858779c75eab8acdd4f4f8ee5b Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 16:51:26 +0900 Subject: [PATCH 117/177] =?UTF-8?q?[9095=201,2,3=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=20=EA=B9=80=EC=B2=A0=ED=98=84]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ9095/Main.java" | 26 +++++++++++++++++++ .../ChulHyeon/src/Main.java" | 5 ---- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ9095/Main.java" delete mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ9095/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ9095/Main.java" new file mode 100644 index 0000000..0e39f45 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ9095/Main.java" @@ -0,0 +1,26 @@ +package BOJ9095; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + int testCase = Integer.parseInt(br.readLine()); + int[] dp = new int[11]; + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i=4; i <= 10;i++){ + dp[i] = dp[i-3] + dp[i-2] + dp[i-1]; + } + + for(int t = 1; t <= testCase; t++) { + int n = Integer.parseInt(br.readLine()); + System.out.println(dp[n]); + } + } +} diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" deleted file mode 100644 index d5238c9..0000000 --- "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" +++ /dev/null @@ -1,5 +0,0 @@ -public class Main { - public static void main(String[] args) { - System.out.println("Hello, World!"); - } -} \ No newline at end of file From 61ce6cff0c2f874206aa6b0ee08eacf213d15803 Mon Sep 17 00:00:00 2001 From: munncoding Date: Mon, 10 Mar 2025 16:54:09 +0900 Subject: [PATCH 118/177] =?UTF-8?q?[1759=20=EC=95=94=ED=98=B8=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20-=2025.03.10]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ1759/Main.java" | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" new file mode 100644 index 0000000..1b2b5cc --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ1759/Main.java" @@ -0,0 +1,72 @@ +package BOJ1759; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + + static int arrlen; + static int alphaCnt; + static char[] arr; + static char[] result; + static boolean[] visit; + + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static StringBuilder sb = new StringBuilder(); + + static void dfs(int cnt, int start) { + if(cnt == arrlen) { + boolean success = false; + int v_count = 0; + for(int idx=0; idx < arrlen; idx++) { + if (result[idx] == 'a' || result[idx] == 'e' || result[idx] == 'i' || result[idx] == 'o' || result[idx] == 'u') + v_count++; + } + if (v_count >= 1 && arrlen - v_count >= 2) + success = true; + if (success) + { + for (int i = 0; i < arrlen; i++) + { + sb.append(result[i]); + } + sb.append('\n'); + } + } + + for(int idx = start; idx < alphaCnt; idx++) { + visit[idx] = true; + result[cnt] = arr[idx]; + dfs(cnt + 1, idx + 1); + visit[idx] = false; + } + } + + public static void main(String[] args) throws IOException { + + st = new StringTokenizer(br.readLine().trim()); + arrlen = Integer.parseInt(st.nextToken()); + alphaCnt = Integer.parseInt(st.nextToken()); + + arr = new char[alphaCnt]; + result = new char[alphaCnt]; + visit = new boolean[alphaCnt]; + + st = new StringTokenizer(br.readLine().trim()); + for(int idx= 0; idx < alphaCnt; idx++) { + arr[idx] = st.nextToken().charAt(0); + } + + Arrays.sort(arr); // 정렬 + + dfs(0,0); + + + System.out.println(sb.toString()); + } +} From 2daa1b7e3db2db136f6ea0b0211338f3980f28f1 Mon Sep 17 00:00:00 2001 From: munncoding Date: Tue, 11 Mar 2025 16:21:42 +0900 Subject: [PATCH 119/177] =?UTF-8?q?[14501=ED=87=B4=EC=82=AC=20-=2025.03.11?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ14501/Main.java" | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14501/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14501/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14501/Main.java" new file mode 100644 index 0000000..19029f2 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14501/Main.java" @@ -0,0 +1,46 @@ +package BOJ14501; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int n; + static int[] t; + static int[] p; + static int[] dp; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + n = Integer.parseInt(br.readLine()); + + // 입력 + t = new int[n + 1]; + p = new int[n + 1]; + + for(int i = 1; i <= n; i++) { + st = new StringTokenizer(br.readLine()); + t[i] = Integer.parseInt(st.nextToken()); + p[i] = Integer.parseInt(st.nextToken()); + } + + dp = new int[n + 2]; + + for (int i = 1; i <= n; i++) { + // 상담을 하는 경우, 퇴사 전에 끝나는지 확인 후 갱신 + if (i + t[i] <= n + 1) { + dp[i + t[i]] = Math.max(dp[i + t[i]], dp[i] + p[i]); + } // i == 1이고 t[1] == 3 이니까 4일차(초반)의 최대값 갱신 + + // i 날에 상담 안했을 때 다음 날로 넘기기 + dp[i + 1] = Math.max(dp[i + 1], dp[i]); + } + + + System.out.println(dp[n + 1]); + } +} From cc172e722252bec0941e8608dcff772e7224df6b Mon Sep 17 00:00:00 2001 From: munncoding Date: Wed, 12 Mar 2025 17:11:57 +0900 Subject: [PATCH 120/177] =?UTF-8?q?[14889=20=EC=8A=A4=ED=83=80=ED=8A=B8?= =?UTF-8?q?=EC=99=80=EB=A7=81=ED=81=AC=20-=2025.03.12]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ14889/Main.java" | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14889/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14889/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14889/Main.java" new file mode 100644 index 0000000..30e58f9 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ14889/Main.java" @@ -0,0 +1,86 @@ +package BOJ14889; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int size; + static int teamSize; + static int[][] arr; + static boolean[] teamA; + static int minimumResult; + + // 조합 + static void combination(int now, int cnt){ + if(cnt >= teamSize) + { + // 조합이 다 되었다면 이제 계산을 해야겠지 + pick(); + return; + } + for(int i = now + 1; i < size; i++){ + teamA[i] = true; + combination( i, cnt + 1); + teamA[i] = false; + } + } + + static void pick(){ + int teamAsum = 0; + int teamBsum = 0; + // 2중 포문으로 2개를 선택해서 + for(int i = 0; i< size;i++) // teamA 하나를 선택하는 반복문 + { + if(teamA[i]) + { + for(int j=i+1; j< size;j++) // teamA 나머지 하나를 선택하는 반복문 + { + if(teamA[j]) + { + teamAsum += arr[i][j]; + teamAsum += arr[j][i]; + } + } + } + else + { + for(int j=i+1; j< size;j++) // teamA 나머지 하나를 선택하는 반복문 + { + if(!teamA[j]) + { + teamBsum += arr[i][j]; + teamBsum += arr[j][i]; + } + } + } + } + minimumResult = Math.min(minimumResult,Math.abs(teamBsum-teamAsum)); + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + size = Integer.parseInt(br.readLine().trim()); + teamSize = size/2; + // 초기화 + arr = new int[size][size]; + teamA = new boolean[size]; + minimumResult = Integer.MAX_VALUE; + // 맵 입력 + for(int i = 0; i < size; i++) { + st = new StringTokenizer(br.readLine().trim(), " "); + for(int j = 0; j < size; j++) { + arr[i][j] = Integer.parseInt(st.nextToken()); + } + } + + // 알고리즘 + combination(-1,0); + + // 출력 + System.out.println(minimumResult); + } +} From 469cbcd8c68603f122b433a3c5420b20440383c0 Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 13 Mar 2025 15:30:47 +0900 Subject: [PATCH 121/177] =?UTF-8?q?[15661=20=EB=A7=81=ED=81=AC=EC=99=80?= =?UTF-8?q?=EC=8A=A4=ED=83=80=ED=8A=B8=20-=2025.03.13]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ15661/Main.java" | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ15661/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ15661/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ15661/Main.java" new file mode 100644 index 0000000..146f5c8 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ15661/Main.java" @@ -0,0 +1,87 @@ +package BOJ15661; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int size; + static int[][] arr; + static boolean[] teamA; + static int minimumResult; + + // 조합 + static void combination(int now, int cnt, int teamSize){ + if(cnt >= teamSize) + { + // 조합이 다 되었다면 이제 계산을 해야겠지 + pick(); + return; + } + for(int i = now + 1; i < size; i++){ + teamA[i] = true; + combination( i, cnt + 1, teamSize); + teamA[i] = false; + } + } + + static void pick(){ + int teamAsum = 0; + int teamBsum = 0; + // 2중 포문으로 2개를 선택해서 + for(int i = 0; i< size;i++) // teamA 하나를 선택하는 반복문 + { + if(teamA[i]) + { + for(int j=i+1; j< size;j++) // teamA 나머지 하나를 선택하는 반복문 + { + if(teamA[j]) + { + teamAsum += arr[i][j]; + teamAsum += arr[j][i]; + } + } + } + else + { + for(int j=i+1; j< size;j++) // teamA 나머지 하나를 선택하는 반복문 + { + if(!teamA[j]) + { + teamBsum += arr[i][j]; + teamBsum += arr[j][i]; + } + } + } + } + minimumResult = Math.min(minimumResult,Math.abs(teamBsum-teamAsum)); + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + StringTokenizer st; + size = Integer.parseInt(br.readLine().trim()); + // 초기화 + arr = new int[size][size]; + teamA = new boolean[size]; + minimumResult = Integer.MAX_VALUE; + // 맵 입력 + for(int i = 0; i < size; i++) { + st = new StringTokenizer(br.readLine().trim(), " "); + for(int j = 0; j < size; j++) { + arr[i][j] = Integer.parseInt(st.nextToken()); + } + } + + // 알고리즘 + for(int i=1;i Date: Thu, 13 Mar 2025 17:25:31 +0900 Subject: [PATCH 122/177] =?UTF-8?q?[2529=20=EB=B6=80=EB=93=B1=ED=98=B8=20-?= =?UTF-8?q?=2025.03.13]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ2529/Main.java" | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ2529/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ2529/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ2529/Main.java" new file mode 100644 index 0000000..29c66d6 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/BOJ2529/Main.java" @@ -0,0 +1,127 @@ +package BOJ2529; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class Main { + static int size; + static char[] cmpArr; + static int[] resultArr; + static boolean[] visit = new boolean[10]; + + static boolean smallFlag = false; + static boolean bigFlag = false; + + static void dfsSmall(int cnt){ + if(cnt > size) + { + if(smallFlag) + return; + smallFlag = true; + for(int a : resultArr) + { + System.out.print(a); + } + System.out.println(); + return; + } + if(smallFlag) + return; + + int cmpIdx = cnt - 1; + + // 시작 부분 가장 처음 인덱스에 넣기 + if(cnt == 0) + { + for(int i = 0; i < 10; i++) + { + visit[i] = true; + resultArr[cnt] = i; + dfsSmall(cnt + 1); + visit[i] = false; + } + return; + } + // 작은 배열 찾기 + for(int i = 0; i < 10; i++) + { + if(visit[i]) + continue; + if((cmpArr[cmpIdx] == '<' && resultArr[cnt - 1] < i) || (cmpArr[cmpIdx] == '>' && resultArr[cnt - 1] > i)) // 현재가 더 커야 한다면 + { + visit[i] = true; + resultArr[cnt] = i; + dfsSmall(cnt + 1); + visit[i] = false; + } + } + } + + static void dfsBig(int cnt){ + if(cnt > size) + { + if(bigFlag) + return; + bigFlag = true; + for(int a : resultArr) + { + System.out.print(a); + } + System.out.println(); + return; + } + if(bigFlag) + return; + + int cmpIdx = cnt - 1; + + // 시작 부분 가장 처음 인덱스에 넣기 + if(cnt == 0) + { + for(int i = 9; i >= 0; i--) + { + visit[i] = true; + resultArr[cnt] = i; + dfsBig(cnt + 1); + visit[i] = false; + } + return; + } + // 큰 배열 찾기 + for(int i = 9; i >= 0; i--) + { + if(visit[i]) + continue; + if((cmpArr[cmpIdx] == '<' && resultArr[cnt - 1] < i) || (cmpArr[cmpIdx] == '>' && resultArr[cnt - 1] > i)) // 현재가 더 커야 한다면 + { + visit[i] = true; + resultArr[cnt] = i; + dfsBig(cnt + 1); + visit[i] = false; + } + } + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + StringBuilder sb = new StringBuilder(); + + // 입력 + size = Integer.parseInt(br.readLine()); + cmpArr = new char[size]; + resultArr = new int[size + 1]; + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < size; i++) { + cmpArr[i] = st.nextToken().charAt(0); + } + + dfsBig(0); + // resultArr 초기화 + dfsSmall(0); + + } +} From 36f440708fdf988431153b49333e53497b6160c9 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 16 Mar 2025 15:26:41 +0900 Subject: [PATCH 123/177] =?UTF-8?q?3=EC=9B=942=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=ED=8F=B4=EB=8D=94=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" | 0 ...\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" | 0 ...\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" | 0 ...\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" | 0 .../HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" => "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" => "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" => "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" => "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" => "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" (100%) diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" "b/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" rename to "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" "b/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" rename to "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" "b/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" rename to "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" "b/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" rename to "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" "b/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" rename to "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" From 17a1abc2c013f6dafecd50e635d2dd8f086a2dd4 Mon Sep 17 00:00:00 2001 From: rlaqkaql1012 Date: Wed, 19 Mar 2025 17:12:49 +0900 Subject: [PATCH 124/177] =?UTF-8?q?[9095=201,2,3,=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-25.02.12=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ_9095/Main" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" diff --git "a/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" "b/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" new file mode 100644 index 0000000..8fa8b4a --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" @@ -0,0 +1,25 @@ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +public class Main { + static int[] dp = new int[12]; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int T = Integer.parseInt(br.readLine()); + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i = 4; i<12;i++) { + dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; + } + for (int test_case = 1 ; test_case<=T;test_case++) { + int n = Integer.parseInt(br.readLine()); + bw.write(dp[n]+"\n"); + } + bw.flush(); + + } +} \ No newline at end of file From 75f0cfa7ec7945a6b06399cec6558b7ca373543d Mon Sep 17 00:00:00 2001 From: rlaqkaql1012 Date: Wed, 19 Mar 2025 17:15:49 +0900 Subject: [PATCH 125/177] =?UTF-8?q?[1759=20=EC=95=94=ED=98=B8=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20-=2025.03.06]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EunJae/BOJ_1759/Main.java" | 110 ++++++++++++++++++ .../EunJae/BOJ_9095/Main.java" | 1 + 2 files changed, 111 insertions(+) create mode 100644 "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" rename "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" => "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" (97%) diff --git "a/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" "b/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" new file mode 100644 index 0000000..1d2bcf1 --- /dev/null +++ "b/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" @@ -0,0 +1,110 @@ +package BOJ_1759; + +import java.io.*; +import java.util.*; + +public class Main { + static int L, C; + static char[] elements; + static List results = new ArrayList<>(); + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + // Read L and C + StringTokenizer st = new StringTokenizer(br.readLine()); + L = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + + // Read the characters + elements = new char[C]; + st = new StringTokenizer(br.readLine()); + for (int i = 0; i < C; i++) { + elements[i] = st.nextToken().charAt(0); + } + + // Sort the elements to ensure the combinations are generated in lexicographical + // order + Arrays.sort(elements); + + // Separate vowels and consonants + List vowels = new ArrayList<>(); + List consonants = new ArrayList<>(); + for (char c : elements) { + if ("aeiou".indexOf(c) >= 0) { + vowels.add(c); + } else { + consonants.add(c); + } + } + + // Generate valid combinations of vowels and consonants + generateCombinations(vowels, consonants); + + // Sort the results + Collections.sort(results); + + // Print the results + for (String result : results) { + bw.write(result + "\n"); + } + + bw.flush(); + bw.close(); + } + + // Generate all valid combinations of vowels and consonants + private static void generateCombinations(List vowels, List consonants) { + // Iterate over all possible numbers of vowels from 1 to min(L-2, vowels.size()) + for (int i = 1; i <= Math.min(L - 2, vowels.size()); i++) { + // Generate combinations of i vowels + List> vowelCombinations = getCombinations(vowels, i); + + // Generate combinations of L-i consonants + List> consonantCombinations = getCombinations(consonants, L - i); + + // Combine vowels and consonants + for (List vowelCombination : vowelCombinations) { + for (List consonantCombination : consonantCombinations) { + // Combine and sort the characters, then convert to string + List combined = new ArrayList<>(vowelCombination); + combined.addAll(consonantCombination); + Collections.sort(combined); + results.add(new String(toCharArray(combined))); + } + } + } + } + + // Helper function to generate combinations + private static List> getCombinations(List list, int count) { + List> combinations = new ArrayList<>(); + backtrack(combinations, list, new ArrayList<>(), 0, count); + return combinations; + } + + // Helper function to backtrack and generate combinations + private static void backtrack(List> combinations, List list, + List current, int start, int count) { + if (current.size() == count) { + combinations.add(new ArrayList<>(current)); + return; + } + + for (int i = start; i < list.size(); i++) { + current.add(list.get(i)); + backtrack(combinations, list, current, i + 1, count); + current.remove(current.size() - 1); + } + } + + // Convert a list of characters to a char array + private static char[] toCharArray(List list) { + char[] array = new char[list.size()]; + for (int i = 0; i < list.size(); i++) { + array[i] = list.get(i); + } + return array; + } +} diff --git "a/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" "b/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" similarity index 97% rename from "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" rename to "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" index 8fa8b4a..b9de7a4 100644 --- "a/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main" +++ "b/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" @@ -1,3 +1,4 @@ +package BOJ_9095; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; From 9c752cf233c9e588fa6824c297c338925ca9cb2e Mon Sep 17 00:00:00 2001 From: rlaqkaql1012 Date: Wed, 19 Mar 2025 17:17:07 +0900 Subject: [PATCH 126/177] =?UTF-8?q?=ED=8F=B4=EB=8D=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 0 .../ChulHyeon/.idea/.gitignore" | 0 .../ChulHyeon/src/Main.java" | 0 .../EunJae/BOJ_1759/Main.java" | 0 .../EunJae/BOJ_9095/Main.java" | 0 .../HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" | 0 ...\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" | 0 ...\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" | 0 ...\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" | 0 .../HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" => "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" (100%) rename "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" => "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" (100%) rename "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" (100%) diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.gitignore" rename to "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" rename to "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" diff --git "a/3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/ChulHyeon/src/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" From 9a42c754ccdd7bf48bdd1fb11986ea9af7bb03e5 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Wed, 19 Mar 2025 17:21:21 +0900 Subject: [PATCH 127/177] =?UTF-8?q?=ED=8F=B4=EB=8D=94=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" | 0 ...\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" | 0 ...\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" | 0 ...\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" | 0 .../HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" (100%) rename "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" => "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" (100%) diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" diff --git "a/3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" similarity index 100% rename from "3\354\233\2242\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" rename to "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" From 462b9ecdc623cb83698099944eb9ac065e605a93 Mon Sep 17 00:00:00 2001 From: rlaqkaql1012 Date: Wed, 19 Mar 2025 17:24:10 +0900 Subject: [PATCH 128/177] =?UTF-8?q?=ED=8F=B4=EB=8D=94=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=93=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 ----- .../ChulHyeon/.idea/.gitignore" | 8 -- .../ChulHyeon/src/Main.java" | 5 - .../EUNJAE/BOJ14501/Main.java" | 0 .../EUNJAE/BOJ14889/Main.java" | 0 .../EUNJAE/BOJ15661/Main.java" | 0 .../EUNJAE/BOJ1759/Main.java" | 0 .../EUNJAE/BOJ2529/Main.java" | 0 .../EUNJAE/BOJ9095/Main.java" | 0 .../EunJae/BOJ_1759/Main.java" | 110 ------------------ .../EunJae/BOJ_9095/Main.java" | 26 ----- .../BOJ_14501_\355\207\264\354\202\254.java" | 55 --------- ...\354\231\200\353\247\201\355\201\254.java" | 64 ---------- ...\354\212\244\355\203\200\355\212\270.java" | 68 ----------- ...\353\247\214\353\223\244\352\270\260.java" | 74 ------------ ...\353\266\200\353\223\261\355\230\270.java" | 84 ------------- 16 files changed, 523 deletions(-) delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" rename "2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ14501/Main.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ14889/Main.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ15661/Main.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ1759/Main.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ2529/Main.java" (100%) rename "2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" => "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ9095/Main.java" (100%) delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" delete mode 100644 "3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" diff --git "a/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" deleted file mode 100644 index f68d109..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.gitignore" +++ /dev/null @@ -1,29 +0,0 @@ -### IntelliJ IDEA ### -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git "a/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" deleted file mode 100644 index c3f502a..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" +++ /dev/null @@ -1,8 +0,0 @@ -# 디폴트 무시된 파일 -/shelf/ -/workspace.xml -# 에디터 기반 HTTP 클라이언트 요청 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git "a/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" deleted file mode 100644 index d5238c9..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/ChulHyeon/src/Main.java" +++ /dev/null @@ -1,5 +0,0 @@ -public class Main { - public static void main(String[] args) { - System.out.println("Hello, World!"); - } -} \ No newline at end of file diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ14501/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/BOJ14501/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ14501/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ14889/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/BOJ14889/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ14889/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ15661/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/BOJ15661/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ15661/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ1759/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/BOJ1759/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ1759/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ2529/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/BOJ2529/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ2529/Main.java" diff --git "a/2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ9095/Main.java" similarity index 100% rename from "2\354\233\224 3\354\243\274\354\260\250/BOJ9095/Main.java" rename to "3\354\233\224 2\354\243\274\354\260\250/EUNJAE/BOJ9095/Main.java" diff --git "a/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" deleted file mode 100644 index 1d2bcf1..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_1759/Main.java" +++ /dev/null @@ -1,110 +0,0 @@ -package BOJ_1759; - -import java.io.*; -import java.util.*; - -public class Main { - static int L, C; - static char[] elements; - static List results = new ArrayList<>(); - - public static void main(String[] args) throws Exception { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); - - // Read L and C - StringTokenizer st = new StringTokenizer(br.readLine()); - L = Integer.parseInt(st.nextToken()); - C = Integer.parseInt(st.nextToken()); - - // Read the characters - elements = new char[C]; - st = new StringTokenizer(br.readLine()); - for (int i = 0; i < C; i++) { - elements[i] = st.nextToken().charAt(0); - } - - // Sort the elements to ensure the combinations are generated in lexicographical - // order - Arrays.sort(elements); - - // Separate vowels and consonants - List vowels = new ArrayList<>(); - List consonants = new ArrayList<>(); - for (char c : elements) { - if ("aeiou".indexOf(c) >= 0) { - vowels.add(c); - } else { - consonants.add(c); - } - } - - // Generate valid combinations of vowels and consonants - generateCombinations(vowels, consonants); - - // Sort the results - Collections.sort(results); - - // Print the results - for (String result : results) { - bw.write(result + "\n"); - } - - bw.flush(); - bw.close(); - } - - // Generate all valid combinations of vowels and consonants - private static void generateCombinations(List vowels, List consonants) { - // Iterate over all possible numbers of vowels from 1 to min(L-2, vowels.size()) - for (int i = 1; i <= Math.min(L - 2, vowels.size()); i++) { - // Generate combinations of i vowels - List> vowelCombinations = getCombinations(vowels, i); - - // Generate combinations of L-i consonants - List> consonantCombinations = getCombinations(consonants, L - i); - - // Combine vowels and consonants - for (List vowelCombination : vowelCombinations) { - for (List consonantCombination : consonantCombinations) { - // Combine and sort the characters, then convert to string - List combined = new ArrayList<>(vowelCombination); - combined.addAll(consonantCombination); - Collections.sort(combined); - results.add(new String(toCharArray(combined))); - } - } - } - } - - // Helper function to generate combinations - private static List> getCombinations(List list, int count) { - List> combinations = new ArrayList<>(); - backtrack(combinations, list, new ArrayList<>(), 0, count); - return combinations; - } - - // Helper function to backtrack and generate combinations - private static void backtrack(List> combinations, List list, - List current, int start, int count) { - if (current.size() == count) { - combinations.add(new ArrayList<>(current)); - return; - } - - for (int i = start; i < list.size(); i++) { - current.add(list.get(i)); - backtrack(combinations, list, current, i + 1, count); - current.remove(current.size() - 1); - } - } - - // Convert a list of characters to a char array - private static char[] toCharArray(List list) { - char[] array = new char[list.size()]; - for (int i = 0; i < list.size(); i++) { - array[i] = list.get(i); - } - return array; - } -} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" deleted file mode 100644 index b9de7a4..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/EunJae/BOJ_9095/Main.java" +++ /dev/null @@ -1,26 +0,0 @@ -package BOJ_9095; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -public class Main { - static int[] dp = new int[12]; - public static void main(String[] args) throws Exception{ - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); - int T = Integer.parseInt(br.readLine()); - - dp[1] = 1; - dp[2] = 2; - dp[3] = 4; - for(int i = 4; i<12;i++) { - dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; - } - for (int test_case = 1 ; test_case<=T;test_case++) { - int n = Integer.parseInt(br.readLine()); - bw.write(dp[n]+"\n"); - } - bw.flush(); - - } -} \ No newline at end of file diff --git "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" deleted file mode 100644 index 09b9d0b..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14501_\355\207\264\354\202\254.java" +++ /dev/null @@ -1,55 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.StringTokenizer; - -public class BOJ_14501_퇴사 { - static int n; - static int[] days; - static int[] fee; - static int maxFee; - static int totalFee; - - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - n = Integer.parseInt(br.readLine()); - days = new int[n]; - fee = new int[n]; - maxFee = 0; - totalFee = 0; - - // 기간과 금액 입력받음. - for (int idx = 0; idx < n; idx++) { - st = new StringTokenizer(br.readLine()); - days[idx] = Integer.parseInt(st.nextToken()); - fee[idx] = Integer.parseInt(st.nextToken()); - } - - // 재귀호출 Start - acceptCounsel(0); - - System.out.println(maxFee); - - } - - public static void acceptCounsel(int dayIdx) { - // 종료조건 - if (dayIdx >= n) { - maxFee = Math.max(maxFee, totalFee); - return; - } - - // 1. dayIdx날 선택하는 경우 - if (dayIdx + days[dayIdx] <= n) { - - totalFee += fee[dayIdx]; - acceptCounsel(dayIdx + days[dayIdx]); - totalFee -= fee[dayIdx]; - } - - // 2. dayIdx날에 상담을 선택하지 않고 다음날로 넘어감. - acceptCounsel(dayIdx + 1); - - } -} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" deleted file mode 100644 index 3298695..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_14889_\354\212\244\355\203\200\355\212\270\354\231\200\353\247\201\355\201\254.java" +++ /dev/null @@ -1,64 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.util.StringTokenizer; -import java.io.InputStreamReader; - -public class BOJ_14889_스타트와링크 { - static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - static StringBuilder sb = new StringBuilder(); - static StringTokenizer st; - static int[][] stats; - static int N, minDiff; - static boolean[] isSelected = new boolean[20]; - - public static void main(String[] args) throws IOException { - - N = Integer.parseInt(br.readLine()); // 총 인원 - stats = new int[N][N]; - - for (int row = 0; row < N; row++) { - st = new StringTokenizer(br.readLine()); - for (int col = 0; col < N; col++) { - stats[row][col] = Integer.parseInt(st.nextToken()); - } - } - - minDiff = Integer.MAX_VALUE; - makeComb(0, 0); - - System.out.println(minDiff); - } - - public static void makeComb(int count, int itemIdx) { - // 한 팀(n/2)를 다 뽑았을 때. - if (count == N / 2) { - int teamAStats = 0, teamBStats = 0; - - // teamA, teamB의 능력치 계산 - for (int i = 0; i < N; i++) { - for (int j = 0; j < N; j++) { - if (isSelected[i] && isSelected[j]) { - teamAStats += stats[i][j]; - } - if (!isSelected[i] && !isSelected[j]) { - teamBStats += stats[i][j]; - } - } - } - - minDiff = Math.min(minDiff, Math.abs(teamAStats - teamBStats)); - return; - } - - if (itemIdx == N - 1) { - return; - } - - isSelected[itemIdx] = true; - makeComb(count + 1, itemIdx + 1); - isSelected[itemIdx] = false; - makeComb(count, itemIdx + 1); - - } - -} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" deleted file mode 100644 index bc4630c..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_15661_\353\247\201\355\201\254\354\231\200\354\212\244\355\203\200\355\212\270.java" +++ /dev/null @@ -1,68 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.util.StringTokenizer; -import java.io.InputStreamReader; - -public class BOJ_15661_링크와스타트 { - static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - static StringBuilder sb = new StringBuilder(); - static StringTokenizer st; - static int[][] stats; - static int N, minDiff; - static boolean[] isSelected = new boolean[20]; - - public static void main(String[] args) throws IOException { - - N = Integer.parseInt(br.readLine()); // 총 인원 - stats = new int[N][N]; // 능력치 - - // 입력받음 - for (int row = 0; row < N; row++) { - st = new StringTokenizer(br.readLine()); - for (int col = 0; col < N; col++) { - stats[row][col] = Integer.parseInt(st.nextToken()); - } - } - - minDiff = Integer.MAX_VALUE; // 능력치의 차이 최솟값 - makeSubset(0); // 부분집합 계산 - - System.out.println(minDiff); - } - - public static void makeSubset(int count) { - - int teamAStats = 0, teamBStats = 0, teamACount = 0; - // teamA, teamB의 능력치 계산 - for (int i = 0; i < N; i++) { - if (isSelected[i] == true) { - teamACount += 1; // teamA의 인원 계산 - } - for (int j = 0; j < N; j++) { - // stats[][] 전체 순회하면서 둘이 같은 팀일경우 능력치에 더함. - if (isSelected[i] && isSelected[j]) { - teamAStats += stats[i][j]; - } - if (!isSelected[i] && !isSelected[j]) { - teamBStats += stats[i][j]; - } - } - } - - // teamA의 인원이 1명 이상 총인원 미만인 경우만 능력치 최솟값 업데이트 - if (teamACount >= 1 && teamACount < N) { - minDiff = Math.min(minDiff, Math.abs(teamAStats - teamBStats)); - } - - if (count == N - 1) { // 총인원 다 고려했을 때 -> return - return; - } - - isSelected[count] = true; - makeSubset(count + 1); - isSelected[count] = false; - makeSubset(count + 1); - - } - -} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" deleted file mode 100644 index 90ccd65..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_1759_\354\225\224\355\230\270\353\247\214\353\223\244\352\270\260.java" +++ /dev/null @@ -1,74 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.util.Arrays; -import java.util.StringTokenizer; -import java.io.InputStreamReader; - -public class BOJ_1759_암호만들기 { - static StringBuilder sb = new StringBuilder(); - static StringTokenizer st; - static char chars[]; - static int[] nums = new int[8]; - static int isVowel, L, C; - - public static void main(String[] args) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - st = new StringTokenizer(br.readLine()); - L = Integer.parseInt(st.nextToken()); // 암호의 길이 - C = Integer.parseInt(st.nextToken()); // 가능성 있는 문자의 개수 - chars = new char[C]; - - st = new StringTokenizer(br.readLine()); - for (int idx = 0; idx < C; idx++) { - chars[idx] = st.nextToken().charAt(0); - } - Arrays.sort(chars); // 입력받아서 사전순으로 정렬. - - // 비트연산 위해 모음의 인덱스에 1의 값을 넣은 isVowel 초기화 - for (int idx = 0; idx < C; idx++) { - int c = chars[idx]; - if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { - isVowel |= (1 << idx); - } - } - - // 가능한 암호 찾기 - makeSubset(0, 0); - - System.out.println(sb); - - } - - public static void makeSubset(int count, int selectedInfo) { // 현재 고려 요소 idx, 선택된 문자 bitmask - - int selectedCharCount = Integer.bitCount(selectedInfo); - int vowelCount = Integer.bitCount(selectedInfo & isVowel); - - // 선택된 문자의 개수가 암호의 길이와 같은 경우 - if (selectedCharCount == L) { - // 모음의 개수가 1이상, 자음의 개수가 2이상인 경우 - if (vowelCount >= 1 && (selectedCharCount - vowelCount) >= 2) { - // 선택된 문자들 출력 - for (int idx = 0; idx < C; idx++) { - if ((selectedInfo & (1 << idx)) != 0) { - sb.append(chars[idx]); - } - } - sb.append('\n'); - } - - return; - } - - // 모든 요소를 다 고려했을 경우 재귀 호출 종료. - if (count == C) { - return; - } - - // 현재 고려요소 + 1, 현재 요소 선택한 다음 재귀 호출 - makeSubset(count + 1, selectedInfo | (1 << count)); - // 고려요소에 +1 해주고 재귀 호출. - makeSubset(count + 1, selectedInfo); - - } -} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" "b/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" deleted file mode 100644 index 12fe50f..0000000 --- "a/3\354\233\224 2\354\243\274\354\260\250/HeeGyeong/BOJ_2529_\353\266\200\353\223\261\355\230\270.java" +++ /dev/null @@ -1,84 +0,0 @@ - -import java.io.BufferedReader; -import java.io.IOException; -import java.util.StringTokenizer; -import java.io.InputStreamReader; - -public class BOJ_2529_부등호 { - static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - static StringBuilder sb = new StringBuilder(); - static StringTokenizer st; - static char[] signs; - static int N, k; - static int[] pArr; - static boolean[] isSelected = new boolean[10]; - static String min = "9999999999", max = "0"; - - public static void main(String[] args) throws IOException { - - k = Integer.parseInt(br.readLine()); // 부등호 개수 - signs = new char[k]; // 부등호 순서 - pArr = new int[k + 1]; // 순열 저장할 배열 - - // 부등호 입력받음 - st = new StringTokenizer(br.readLine()); - for (int idx = 0; idx < k; idx++) { - signs[idx] = st.nextToken().charAt(0); - } - - makePerm(0); - - sb.append(max).append('\n').append(min); - System.out.println(sb); - } - - public static void makePerm(int count) { - - if (count == k + 1) { - boolean flag = true; - // 가능한 순열인지 확인. - for (int idx = 0; idx < k; idx++) { - switch (signs[idx]) { - case '<': - if (pArr[idx] > pArr[idx + 1]) { - flag = false; - } - break; - case '>': - if (pArr[idx] < pArr[idx + 1]) { - flag = false; - } - break; - } - } - - // 가능한 순열이면 - if (flag == true) { - StringBuilder sb = new StringBuilder(); - for (int num : pArr) { - sb.append(num); - } - String numStr = sb.toString(); - - if (numStr.compareTo(min) < 0) { - min = numStr; - } - if (numStr.compareTo(max) > 0) { - max = numStr; - } - } - return; - } - - for (int idx = 0; idx <= 9; idx++) { - if (isSelected[idx] == false) { - isSelected[idx] = true; - pArr[count] = idx; - makePerm(count + 1); - isSelected[idx] = false; - } - } - - } - -} \ No newline at end of file From 30eda4ea44f5f271897d68f6b5a5f2f1b6d32c8f Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Wed, 19 Mar 2025 17:24:57 +0900 Subject: [PATCH 129/177] =?UTF-8?q?[1463=201=EB=A1=9C=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EA=B8=B0=20-=2025.03.19]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\247\214\353\223\244\352\270\260.java" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1463_1\353\241\234\353\247\214\353\223\244\352\270\260.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1463_1\353\241\234\353\247\214\353\223\244\352\270\260.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1463_1\353\241\234\353\247\214\353\223\244\352\270\260.java" new file mode 100644 index 0000000..f76eecb --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_1463_1\353\241\234\353\247\214\353\223\244\352\270\260.java" @@ -0,0 +1,32 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class BOJ_1463_1로만들기 { + static Scanner sc; + static int[] dp; + static int N; + + public static void main(String[] args) { + sc = new Scanner(System.in); + N = sc.nextInt(); // 주어진 정수 + dp = new int[N + 1]; + Arrays.fill(dp, Integer.MAX_VALUE); + dp[N] = 0; + + for (int idx = N; idx >= 2; idx--) { + int curCount = dp[idx]; + if (idx % 3 == 0 && curCount + 1 < dp[idx / 3]) { + dp[idx / 3] = curCount + 1; + } + if (idx % 2 == 0 && curCount + 1 < dp[idx / 2]) { + dp[idx / 2] = curCount + 1; + } + if (curCount + 1 < dp[idx - 1]) { + dp[idx - 1] = curCount + 1; + } + } + + System.out.println(dp[1]); + } + +} From 27c4fd561faf3ba60eb020a652b80df998958e5c Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Mar 2025 20:06:29 +0900 Subject: [PATCH 130/177] =?UTF-8?q?3=EC=9B=94=203=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=ED=8F=B4=EB=8D=94=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.gitignore" | 29 +++++++++++++++++++ .../ChulHyeon/src/Main.java" | 5 ++++ 2 files changed, 34 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/Main.java" new file mode 100644 index 0000000..d5238c9 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/Main.java" @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} \ No newline at end of file From ce4691f58924949f2f328a2c405240d480657987 Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Mar 2025 20:06:51 +0900 Subject: [PATCH 131/177] =?UTF-8?q?3=EC=9B=94=203=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=ED=8F=B4=EB=8D=94=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/.idea/.gitignore" | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml From 4a176983dba0821a58cd2bb3a39b23ed448d52a5 Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Mar 2025 20:30:57 +0900 Subject: [PATCH 132/177] =?UTF-8?q?3=EC=9B=94=203=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=EA=B9=80=EC=B2=A0=ED=98=84=20=ED=8C=8C=EC=9D=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.idea/.gitignore" | 8 +++++ .../ChulHyeon/.gitignore" | 29 +++++++++++++++++++ .../ChulHyeon/.idea/.gitignore" | 8 +++++ 3 files changed, 45 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/.idea/.gitignore" create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" diff --git "a/3\354\233\2243\354\243\274\354\260\250/.idea/.gitignore" "b/3\354\233\2243\354\243\274\354\260\250/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" new file mode 100644 index 0000000..f68d109 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.gitignore" @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" new file mode 100644 index 0000000..c3f502a --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/.idea/.gitignore" @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml From 1a292b25183ecd3bcb3d6c59c8f5420b07145b23 Mon Sep 17 00:00:00 2001 From: munncoding Date: Thu, 20 Mar 2025 20:31:26 +0900 Subject: [PATCH 133/177] =?UTF-8?q?[1463=201=EB=A1=9C=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EA=B8=B0=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ1463/Main.java" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ1463/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ1463/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ1463/Main.java" new file mode 100644 index 0000000..77e4245 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ1463/Main.java" @@ -0,0 +1,51 @@ +package BOJ1463; + +/* +* +* 3으로 나눌수 있으면 3으로 나누기 +* 2로 나누어지면 2로 나누기 +* 1을 뺴기 +* +* 3개 중 하나 +* +* N이 주어졌을 때 3개 중 하나 써서 1로 만들기 +* +* */ + +import java.util.Arrays; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + // dp 설정 해서 최소 카운트 갱신 되면 해당 걸로 진행 + int dp[] = new int[n + 1]; + // 초기화 + Arrays.fill(dp, Integer.MAX_VALUE - 10); + dp[n] = 0; + + for(int i=n;i>=1;i--) + { + // 1을 뺀 경우 + int tmp = i + 1; + if(tmp > n) + continue; + dp[i] = Math.min(dp[i], dp[tmp] + 1); + // 2로 나눈 경우 + tmp = i * 2; + if(tmp > n) + continue; + dp[i] = Math.min(dp[i], dp[tmp] + 1); + // 3으로 나눈 경우 + tmp = i * 3; + if(tmp > n) + continue; + dp[i] = Math.min(dp[i], dp[tmp] + 1); + } + + + System.out.println(dp[1]); + } +} From cc291d27a5d6b275f0bf2eef68eb95b53f6a8d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Thu, 20 Mar 2025 22:40:58 +0900 Subject: [PATCH 134/177] =?UTF-8?q?[1463.=201=EB=A1=9C=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EA=B8=B0=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ1463/boj1463.java" | 29 +++++++++++++++++++ .../BOJ1463/boj1463_2.java" | 5 ++++ 2 files changed, 34 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" new file mode 100644 index 0000000..1ec70ff --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" @@ -0,0 +1,29 @@ +package march3; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +public class boj1463 { + static BufferedReader br; + static int N; + static int[] dp; + public static void main(String[] args) throws Exception { + br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + dp = new int[1000001]; + dp[1] =0; + for(int i = 2; i<1000001;i++) { + dp[i] = dp[i-1]+1; + + if(i%2==0) { + dp[i]= Math.min(dp[i],dp[i/2]+1); + } + if(i%3==0) { + dp[i] = Math.min(dp[i],dp[i/3]+1); + } + } + System.out.println(dp[N]); + + +} +} diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" new file mode 100644 index 0000000..9a2911b --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" @@ -0,0 +1,5 @@ +package march3; + +public class boj1463_2 { + +} From fbd7766318dee23c1a7776563077593decbcea41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Thu, 20 Mar 2025 22:52:28 +0900 Subject: [PATCH 135/177] =?UTF-8?q?[11726=202xn=ED=83=80=EC=9D=BC=EB=A7=81?= =?UTF-8?q?=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...203\200\354\235\274\353\247\201_250320.java" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" new file mode 100644 index 0000000..86b3a87 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" @@ -0,0 +1,17 @@ +package march3; + +import java.util.Scanner; + +public class Main { +public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + int[] dp= new int[1001]; + dp[1]=1; + dp[2]=2; + for(int i = 3;i<=1000;i++) { + dp[i] = (dp[i-1] + dp[i-2])%10007; + } + System.out.println(dp[N]); +} +} From 21edff3acbbe22e094ab2e8728cae65b3adb7bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Thu, 20 Mar 2025 22:53:15 +0900 Subject: [PATCH 136/177] =?UTF-8?q?[11727=202xn=ED=83=80=EC=9D=BC=EB=A7=81?= =?UTF-8?q?2=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...03\200\354\235\274\353\247\2012_250320.java" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" new file mode 100644 index 0000000..c613d57 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" @@ -0,0 +1,17 @@ +package march3; + +import java.util.Scanner; + +public class boj11727 { +public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + int[] dp= new int[1001]; + dp[1]=1; + dp[2]=3; + for(int i = 3;i<=1000;i++) { + dp[i] = (dp[i-1] + dp[i-2]<<1)%10007; + } + System.out.println(dp[N]); +} +} From de7f2c31b774625c2a34a6a213640729d84ad5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Thu, 20 Mar 2025 22:56:00 +0900 Subject: [PATCH 137/177] =?UTF-8?q?[9095=20123=EB=8D=94=ED=95=98=EA=B8=B0?= =?UTF-8?q?=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\224\355\225\230\352\270\260_250320.java" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" new file mode 100644 index 0000000..93c4371 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" @@ -0,0 +1,29 @@ +package march3; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + + + +public class BOJ9095_123더하기_250320 { + static int[] dp = new int[12]; + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + int T = Integer.parseInt(br.readLine()); + + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i = 4; i<12;i++) { + dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; + } + for (int test_case = 1 ; test_case<=T;test_case++) { + int n = Integer.parseInt(br.readLine()); + bw.write(dp[n]+"\n"); + } + bw.flush(); + + } +} From 561b6e2dae67d58b5b0fccaaf59b5a43babb9184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Thu, 20 Mar 2025 23:49:13 +0900 Subject: [PATCH 138/177] =?UTF-8?q?[11052=20=EC=B9=B4=EB=93=9C=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B0=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7\244\355\225\230\352\270\260_250320.java" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" new file mode 100644 index 0000000..e5e8238 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" @@ -0,0 +1,30 @@ +package march3; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ11052_카드구매하기_250320 { + static BufferedReader br; + static StringTokenizer st; + static int N; + static int[] card; + public static void main(String[] args) throws Exception{ + br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + card = new int[N+1]; + st = new StringTokenizer(br.readLine()); + for(int i=1;i<=N;i++) { + card[i]= Integer.parseInt(st.nextToken()); + + } + + for(int i=1;i<=N/2;i++) { + for(int j=i;j+i<=N;j++) { + card[i+j] = Math.max(card[i+j], card[i]+card[j]); + } + } + + System.out.println(card[N]); + } +} From 4d4357ad4f3a0ee0ca2e7532b8db631ea619d661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Thu, 20 Mar 2025 23:52:07 +0900 Subject: [PATCH 139/177] =?UTF-8?q?[16194=20=EC=B9=B4=EB=93=9C=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B02=20-=2025.03.20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\244\355\225\230\352\270\2602_250320.java" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" new file mode 100644 index 0000000..0be1384 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" @@ -0,0 +1,30 @@ +package march3; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ16194_카드구매하기2_250320{ + static BufferedReader br; + static StringTokenizer st; + static int N; + static int[] card; + public static void main(String[] args) throws Exception{ + br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + card = new int[N+1]; + st = new StringTokenizer(br.readLine()); + for(int i=1;i<=N;i++) { + card[i]= Integer.parseInt(st.nextToken()); + + } + + for(int i=1;i<=N/2;i++) { + for(int j=i;j+i<=N;j++) { + card[i+j] = Math.min(card[i+j], card[i]+card[j]); + } + } + + System.out.println(card[N]); + } +} From 9e4e51d18ba65bd5198f7ab5e6fa4bc5f4edb495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sat, 22 Mar 2025 13:37:33 +0900 Subject: [PATCH 140/177] =?UTF-8?q?[15990=20123=EB=8D=94=ED=95=98=EA=B8=B0?= =?UTF-8?q?5=20-=2025.03.22]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...15\224\355\225\230\352\270\2605_0322.java" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" new file mode 100644 index 0000000..125bb13 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" @@ -0,0 +1,44 @@ +package march3; + +import java.util.Scanner; +/* + * 정수 4를 1, 2, 3의 합으로 나타내는 방법은 총 3가지가 있다. 합을 나타낼 때는 수를 1개 이상 사용해야 한다. 단, 같은 수를 두 번 이상 연속해서 사용하면 안 된다. + +1+2+1 +1+3 +3+1 +정수 n이 주어졌을 때, n을 1, 2, 3의 합으로 나타내는 방법의 수를 구하는 프로그램을 작성하시오. + */ +public class BOJ15990_123더하기5_0322 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int max = 0; + int T = sc.nextInt(); + int[] N = new int[T]; + for(int tc = 0; tc Date: Sat, 22 Mar 2025 13:59:35 +0900 Subject: [PATCH 141/177] =?UTF-8?q?[10844=20=EC=89=AC=EC=9A=B4=EA=B3=84?= =?UTF-8?q?=EB=8B=A8=EC=88=98=20-=2025.03.22]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\204\353\213\250\354\210\230_250322.java" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" "b/3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" new file mode 100644 index 0000000..5f8ff7a --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" @@ -0,0 +1,34 @@ +package march3; + +import java.util.Scanner; + +/* + * 1 2 3 4 5 6 7 8 9 + * 10 12 21 23 32 34 43 45 54 56 65 67 76 78 87 89 98 + * 9,0으로끝나는것만 +1, 나머지는 +2씩 분기가 늘어남 + * 9의 수 = 이전의 8로 끝난 수 + * 0의 수 = 이전의 1로 끝난 수 + */ +class BOJ10844_쉬운계단수_250322 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + int[][] dp = new int[N+1][10]; + for(int i=1;i<=9;i++) { + dp[1][i] =1; + } + int cnt=0; + for(int i = 2; i<=N;i++) { + dp[i][0] = dp[i-1][1]; + dp[i][9] = dp[i-1][8]; + for(int j =1;j<=8;j++) { + dp[i][j] = dp[i-1][j-1] + dp[i-1][j+1]; + } + } + + for(int i=0;i<=9;i++) { + cnt+=dp[N][i]; + } + System.out.println(cnt); + } +} From 1ebc5caec677f797ad4954729e409df5cb02294d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9D=80=EC=9E=AC?= Date: Sat, 22 Mar 2025 14:10:03 +0900 Subject: [PATCH 142/177] =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" | 0 ...4\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" | 0 .../BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" | 0 ...boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" | 0 .../EunJae/BOJ1463/boj1463.java" | 0 .../EunJae/BOJ1463/boj1463_2.java" | 0 .../BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" | 0 ...\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" | 0 .../BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ1463/boj1463.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ1463/boj1463_2.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" (100%) rename "3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" => "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" (100%) diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ10844/BOJ10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230_250322.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11052/BOJ11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11726/BOJ11726_2xn\355\203\200\354\235\274\353\247\201_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ11727/boj11727_2xn\355\203\200\354\235\274\353\247\2012_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ1463/boj1463.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ1463/boj1463.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ1463/boj1463_2.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ1463/boj1463_2.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ1463/boj1463_2.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ15990/BOJ15990_123\353\215\224\355\225\230\352\270\2605_0322.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ16194/BOJ16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602_250320.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" "b/3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" similarity index 100% rename from "3\354\233\224 3\354\243\274\354\260\250/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" rename to "3\354\233\224 3\354\243\274\354\260\250/EunJae/BOJ9095/BOJ9095_123\353\215\224\355\225\230\352\270\260_250320.java" From 03b6d88aafb43038aa777f2c6d1fe32d9c4b0c0f Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 11:41:15 +0900 Subject: [PATCH 143/177] =?UTF-8?q?3=EC=9B=94=202=EC=A3=BC=EC=B0=A8=20comm?= =?UTF-8?q?it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/Yuri_1248/Main.java" | 69 +++++++++++++++ .../Yuri/Yuri_14501/Main.java" | 47 ++++++++++ .../Yuri/Yuri_14889/Main.java" | 83 ++++++++++++++++++ .../Yuri/Yuri_15661/Main.java" | 85 +++++++++++++++++++ .../Yuri/Yuri_1759/Main.java" | 72 ++++++++++++++++ .../Yuri/Yuri_2529/Main.java" | 78 +++++++++++++++++ 6 files changed, 434 insertions(+) create mode 100644 "3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_1248/Main.java" create mode 100644 "3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_14501/Main.java" create mode 100644 "3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_14889/Main.java" create mode 100644 "3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_15661/Main.java" create mode 100644 "3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_1759/Main.java" create mode 100644 "3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_2529/Main.java" diff --git "a/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_1248/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_1248/Main.java" new file mode 100644 index 0000000..3ac4da4 --- /dev/null +++ "b/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_1248/Main.java" @@ -0,0 +1,69 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + static int n; + static int[] arr; + static char[][] input; + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + n = Integer.parseInt(br.readLine().trim()); + + arr = new int[n]; + input = new char[n][n]; + + String str = br.readLine().trim(); + int num = 0; + for (int i = 0; i < n; i++) { + for (int j = i; j < n; j++) { + input[i][j] = str.charAt(num++); + } + } + + solution(0); + } + + public static void solution(int count) { + + if (count == n) { + for (int num : arr) { + System.out.print(num + " "); + } + System.exit(0); // 프로그램을 종료합니다. + } + + for (int i = -10; i < 11; i++) { + arr[count] = i; + if (isValid(count + 1)) { + solution(count + 1); + } + } + } + + public static boolean isValid(int count) { + for (int i = 0; i < count; i++) { + int sum = 0; + for (int j = i; j < count; j++) { + sum += arr[j]; + switch (input[i][j]) { + case '+': + if (sum <= 0) return false; + break; + case '0': + if (sum != 0) return false; + break; + case '-': + if (sum >= 0) return false; + break; + } + } + } + return true; + } +} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_14501/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_14501/Main.java" new file mode 100644 index 0000000..4273077 --- /dev/null +++ "b/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_14501/Main.java" @@ -0,0 +1,47 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.StringTokenizer; + +public class Main { + static int N; + static ArrayList arr = new ArrayList<>(); + static int Max = 0; + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + N = Integer.parseInt(br.readLine().trim()); + + for(int i=0;i passwords = new ArrayList<>(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + st = new StringTokenizer(br.readLine().trim()); + + L = Integer.parseInt(st.nextToken()); + C = Integer.parseInt(st.nextToken()); + + chars = new char[C]; + result = new char[L]; + + st = new StringTokenizer(br.readLine().trim()); + + for (int i = 0; i < C; i++) { + chars[i] = st.nextToken().charAt(0); + } + + Arrays.sort(chars); + + solution(0, 0); + + for (String password : passwords) { + System.out.println(password); + } + } + + public static void solution(int start, int depth) { + if (depth == L) { + if (isValid(result)) { + passwords.add(new String(result)); + } + return; + } + + for (int i = start; i < C; i++) { + result[depth] = chars[i]; + solution(i + 1, depth + 1); + } + } + + public static boolean isValid(char[] password) { + int vowels = 0; + int consonants = 0; + + for (char c : password) { + if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') { + vowels++; + } else { + consonants++; + } + } + + return vowels >= 1 && consonants >= 2; + } +} diff --git "a/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_2529/Main.java" "b/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_2529/Main.java" new file mode 100644 index 0000000..74e3f0f --- /dev/null +++ "b/3\354\233\224 2\354\243\274\354\260\250/Yuri/Yuri_2529/Main.java" @@ -0,0 +1,78 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + static int k; + static long Max, Min; + static char[] arr; + static boolean[] visited; + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + k = Integer.parseInt(br.readLine().trim()); + arr = new char[k]; + + String[] str = br.readLine().trim().split(" "); + for(int i=0; i ': + if ((str.charAt(count)-'0')>i) { + visited[i] = true; + //System.out.println("2 : "+str+String.valueOf(i)); + solution(count+1,str+String.valueOf(i)); + visited[i]= false; + } + break; + } + + } + } +} From 239a1aac360a206fd43204639d9603df29e7eb21 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 12:52:24 +0900 Subject: [PATCH 144/177] =?UTF-8?q?[1463=201=EB=A1=9C=20=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EA=B8=B0=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_1463/BOJ_1463.java" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_1463/BOJ_1463.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_1463/BOJ_1463.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_1463/BOJ_1463.java" new file mode 100644 index 0000000..745d94e --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_1463/BOJ_1463.java" @@ -0,0 +1,21 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_1463 { + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + + System.out.println(solution(n,0)); + } + + static int solution(int now, int count) { + if(now <= 1) return count; + + return Math.min(solution(now/2, count+1+(now%2)),solution(now/3, count+1+(now%3))); + } +} From f866f05e115885d4111a14bea3f9e124ca974923 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Mar 2025 13:15:21 +0900 Subject: [PATCH 145/177] =?UTF-8?q?[11726=202xn=ED=83=80=EC=9D=BC=EB=A7=81?= =?UTF-8?q?=20-=2025.03.22]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ11726/Main.java" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11726/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11726/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11726/Main.java" new file mode 100644 index 0000000..5cf7259 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11726/Main.java" @@ -0,0 +1,22 @@ +package BOJ11726; + +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] dp = new int[1001]; + + + dp[1] = 1; + dp[2] = 2; + for(int i = 3;i<=n;i++) { + // 이전 꺼에서 ㅣ 자 하나 더하는 경우 + + // 2개 전 꺼에서 ㅡ 자 두개 합치는 경우 + dp[i] = (dp[i-1] + dp[i-2]) % 10007; + } + System.out.println(dp[n]); + } +} From d8b189a8f77a227719696d800bad18bc17c2bb9c Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Mar 2025 13:15:55 +0900 Subject: [PATCH 146/177] =?UTF-8?q?[11727=202xn=ED=83=80=EC=9D=BC=EB=A7=81?= =?UTF-8?q?2=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ11727/Main.java" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11727/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11727/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11727/Main.java" new file mode 100644 index 0000000..82fa4c7 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11727/Main.java" @@ -0,0 +1,27 @@ +package BOJ11727; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Scanner; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] dp = new int[1001]; + + + dp[1] = 1; + dp[2] = 3; // 세로세로 가로가로 2x2 하나 + dp[3] = 5; + for(int i = 4;i<=n;i++) { + // 2칸 전에서 2배 + dp[i] = (dp[i-2] * 2 + dp[i-1]) % 10007; + // 1칸 전 그대로 + + } + System.out.println(dp[n]); + } +} From deb1032064f295e6278df4fd28c9e6c0c6e5a0ad Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 13:23:00 +0900 Subject: [PATCH 147/177] =?UTF-8?q?[11726=202xn=20=ED=83=80=EC=9D=BC?= =?UTF-8?q?=EB=A7=81=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_11726/BOJ_11726.java" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11726/BOJ_11726.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11726/BOJ_11726.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11726/BOJ_11726.java" new file mode 100644 index 0000000..7ae2a98 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11726/BOJ_11726.java" @@ -0,0 +1,24 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_11726 { + // 1 2 3 5 + static int dp[]; + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + dp = new int[1001]; + dp[1] = 1; + dp[2] = 2; + for(int i = 3; i<1001; i++) { + dp[i] = (dp[i-1] + dp[i-2])%10007; + } + System.out.println(dp[n]); + } + + +} From f017d207a2d099527fe98be981bc9b2e31ece326 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Mar 2025 14:03:21 +0900 Subject: [PATCH 148/177] =?UTF-8?q?[11052=20=EC=B9=B4=EB=93=9C=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B0=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ11052/Main.java" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11052/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11052/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11052/Main.java" new file mode 100644 index 0000000..ecdffe8 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ11052/Main.java" @@ -0,0 +1,22 @@ +package BOJ11052; + +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] arr = new int[n + 1]; + int[] dp = new int[n + 1]; + for(int i = 1; i <= n; i++) { + arr[i] = sc.nextInt(); + } + dp[1] = arr[1]; + for(int i = 2; i <= n; i++) { + for(int j = 0; j < i; j++) { + dp[i] = Math.max(dp[i], dp[j] + arr[i-j]); + } + } + System.out.println(dp[n]); + } +} From 6fedb266eb117409dd032077fcabb2d1f76ab518 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Mar 2025 14:26:51 +0900 Subject: [PATCH 149/177] =?UTF-8?q?[16194=20=EC=B9=B4=EB=93=9C=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B02=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ16194/Main.java" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ16194/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ16194/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ16194/Main.java" new file mode 100644 index 0000000..467feae --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ16194/Main.java" @@ -0,0 +1,25 @@ +package BOJ16194; + +import java.util.Arrays; +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] arr = new int[n + 1]; + int[] dp = new int[n + 1]; + for(int i = 1; i <= n; i++) { + arr[i] = sc.nextInt(); + } + Arrays.fill(dp, 99999); + dp[1] = arr[1]; + dp[0] = 0; + for(int i = 2; i <= n; i++) { + for(int j = 0; j < i; j++) { + dp[i] = Math.min(dp[i], dp[j] + arr[i-j]); + } + } + System.out.println(dp[n]); + } +} From 35c93c4e5d751a1f970fdb815c2c4614891d8d2e Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 14:34:52 +0900 Subject: [PATCH 150/177] =?UTF-8?q?[11727=202xn=20=ED=83=80=EC=9D=BC?= =?UTF-8?q?=EB=A7=81=202=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_11727.java" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11727.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11727.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11727.java" new file mode 100644 index 0000000..24faa44 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11727.java" @@ -0,0 +1,24 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_11727 { + // 1 3 5 11 + static int dp[]; + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + dp = new int[1001]; + dp[1] = 1; + dp[2] = 3; + for(int i = 3; i<1001; i++) { + dp[i] = (dp[i-1] + dp[i-2]*2)%10007; + } + System.out.println(dp[n]); + } + + +} From 88e22495f719fbd1d17c6477cb7fe951d827cec6 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 14:40:21 +0900 Subject: [PATCH 151/177] =?UTF-8?q?[9095=201,2,3=20=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_9095.java" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_9095.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_9095.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_9095.java" new file mode 100644 index 0000000..b45a2c1 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_9095.java" @@ -0,0 +1,28 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_9095 { + // 1 3 5 11 + static int dp[]; + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int t = Integer.parseInt(br.readLine().trim()); + dp = new int[12]; + dp[1] = 1; + dp[2] = 2; + dp[3] = 4; + for(int i = 4; i<12; i++) { + dp[i] = dp[i-1] + dp[i-2] + dp[i-3]; + } + for(int test = 0; test Date: Sun, 23 Mar 2025 16:10:51 +0900 Subject: [PATCH 152/177] =?UTF-8?q?[11052=20=EC=B9=B4=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B0=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_11052.java" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11052.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11052.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11052.java" new file mode 100644 index 0000000..6e9d263 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_11052.java" @@ -0,0 +1,30 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_11052 { + static int dp[]; + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + dp = new int[n+1]; + int[] card = new int[n+1]; + StringTokenizer st = new StringTokenizer(br.readLine().trim()); + for(int i=0; i< n;i++) { + card[i+1] = Integer.parseInt(st.nextToken()); + } + for(int i = 1; i<=n;i++) { + for(int j = 1;j<=i;j++) { + dp[i] = Math.max(dp[i], card[j]+dp[i-j]); + } + } + System.out.println(dp[n]); + + } + + +} From a5c7e3ec1a3b734f2ec504ef8abb943723da5f0f Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 16:20:07 +0900 Subject: [PATCH 153/177] =?UTF-8?q?[16194=20=EC=B9=B4=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B02=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_16194.java" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_16194.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_16194.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_16194.java" new file mode 100644 index 0000000..18a5cb5 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_16194.java" @@ -0,0 +1,33 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_16194 { + static int dp[]; + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + dp = new int[n+1]; + Arrays.fill(dp, Integer.MAX_VALUE); + int[] card = new int[n+1]; + StringTokenizer st = new StringTokenizer(br.readLine().trim()); + for(int i=0; i< n;i++) { + card[i+1] = Integer.parseInt(st.nextToken()); + } + dp[0]=0; + for(int i = 1; i<=n;i++) { + for(int j = 1;j<=i;j++) { + dp[i] = Math.min(dp[i], card[j]+dp[i-j]); + } + } + System.out.println(dp[n]); + + } + + +} From c19ef6713e945affdd4ee3a9e5b64fb18b905b2f Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 17:11:51 +0900 Subject: [PATCH 154/177] =?UTF-8?q?[15990=201,2,3=20=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B0=205=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_15990.java" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_15990.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_15990.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_15990.java" new file mode 100644 index 0000000..76347c3 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_15990.java" @@ -0,0 +1,38 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_15990 { + + public static void main(String[] args) throws NumberFormatException, IOException { + int MOD = 1_000_000_009; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int t = Integer.parseInt(br.readLine().trim()); + long[][] dp = new long[100001][4]; + + dp[1][1] = 1; + dp[2][2] = 1; + dp[3][1] = 1; + dp[3][2] = 1; + dp[3][3] = 1; + + for(int i=4;i<100001;i++) { + dp[i][1] = (dp[i-1][2]+dp[i-1][3])%MOD; + dp[i][2] = (dp[i-2][1]+dp[i-2][3])%MOD; + dp[i][3] = (dp[i-3][1]+dp[i-3][2])%MOD; + } + + for(int i=0; i< t;i++) { + int a = Integer.parseInt(br.readLine().trim()); + System.out.println((dp[a][1]+dp[a][2]+ dp[a][3])%MOD); + } + + } + + +} From c4aba0fc068effbf68c9b25b2f6661ba92bcacf7 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Sun, 23 Mar 2025 17:31:08 +0900 Subject: [PATCH 155/177] =?UTF-8?q?[10844=20=EC=89=AC=EC=9A=B4=20=EA=B3=84?= =?UTF-8?q?=EB=8B=A8=20=EC=88=98=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_10844.java" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_10844.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_10844.java" "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_10844.java" new file mode 100644 index 0000000..a93e979 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/Yuri/BOJ_10844.java" @@ -0,0 +1,39 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_10844 { + + public static void main(String[] args) throws NumberFormatException, IOException { + int MOD = 1_000_000_000; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + long[][] dp = new long[101][10]; + + for(int i=1; i<=9;i++) { + dp[1][i] =1; + } + + for(int i=2;i<101;i++) { + dp[i][0] = (dp[i-1][1])%MOD; + dp[i][9] = (dp[i-1][8])%MOD; + for(int j=1; j<9;j++) { + dp[i][j] = (dp[i-1][j-1]+dp[i-1][j+1])%MOD; + } + } + + long result=0; + for(int i=0; i< 10;i++) { + result+=dp[n][i]%MOD; + } + System.out.println(result%MOD); + + } + + +} From fda8d7d65f95573db86ef25d64915e0abf8b62e5 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Mar 2025 19:33:27 +0900 Subject: [PATCH 156/177] =?UTF-8?q?[15990=201,2,3=EB=8D=94=ED=95=98?= =?UTF-8?q?=EA=B8=B05=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ15990/Main.java" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ15990/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ15990/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ15990/Main.java" new file mode 100644 index 0000000..f393588 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ15990/Main.java" @@ -0,0 +1,35 @@ +package BOJ15990; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Scanner; +import java.util.StringTokenizer; + +public class Main { + public static void main(String[] args) throws IOException { + Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); + long[][] dp = new long[100001][4]; + + dp[1][1] = 1; + + dp[2][2] = 1; + + dp[3][1] = 1; + dp[3][2] = 1; + dp[3][3] = 1; + + for(int i = 4; i <= 100000; i++) { + dp[i][1] = (dp[i-1][3] + dp[i-1][2]) % 1000000009; + dp[i][2] = (dp[i-2][1] + dp[i-2][3]) % 1000000009; + dp[i][3] = (dp[i-3][1] + dp[i-3][2]) % 1000000009; + } + + for(int i = 0; i < n; i++) { + int k = sc.nextInt(); + System.out.println((dp[k][1] + dp[k][2] + dp[k][3])%1000000009); + } + } +} From 01903a279eeb6956aca9549e2ea1892384e77fb9 Mon Sep 17 00:00:00 2001 From: munncoding Date: Sun, 23 Mar 2025 19:33:46 +0900 Subject: [PATCH 157/177] =?UTF-8?q?[10844=20=EC=89=AC=EC=9A=B4=EA=B3=84?= =?UTF-8?q?=EB=8B=A8=EC=88=98=20-=2025.03.23]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChulHyeon/src/BOJ10844/Main.java" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ10844/Main.java" diff --git "a/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ10844/Main.java" "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ10844/Main.java" new file mode 100644 index 0000000..d79d4e3 --- /dev/null +++ "b/3\354\233\2243\354\243\274\354\260\250/ChulHyeon/src/BOJ10844/Main.java" @@ -0,0 +1,47 @@ +package BOJ10844; + +import java.util.Scanner; + +/* +* +* 1 => 9 +* 0 으로 시작만 안하면 들어갈 수 있음 +* +* */ + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[][]dp = new int[n + 1][10]; + // 1자리 수 일 경우 + for(int i=1;i<=9;i++) + { + dp[1][i] = 1; + } + for(int i=2;i<=n;i++) + { + for(int j=0;j<=9;j++){ + if(j == 0) + { + dp[i][j] = dp[i-1][j+1]; + continue; + } + if(j == 9) + { + dp[i][j] = dp[i-1][j-1]; + continue; + } + dp[i][j] = (dp[i-1][j-1] + dp[i-1][j+1]) % 1_000_000_000; + } + } + + // 출력 + long result = 0; + for(int i=0;i<=9;i++) + { + result = (result + dp[n][i]) % 1_000_000_000; + } + System.out.println(result); + } +} From 98574514af2a401c45219c76aafcecd189dc223a Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 24 Mar 2025 01:13:40 +0900 Subject: [PATCH 158/177] =?UTF-8?q?[11726=202xn=ED=83=80=EC=9D=BC=EB=A7=81?= =?UTF-8?q?=20-=2025.03.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\203\200\354\235\274\353\247\201.java" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11726_2xn\355\203\200\354\235\274\353\247\201.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11726_2xn\355\203\200\354\235\274\353\247\201.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11726_2xn\355\203\200\354\235\274\353\247\201.java" new file mode 100644 index 0000000..770afe5 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11726_2xn\355\203\200\354\235\274\353\247\201.java" @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class BOJ_11726_2xn타일링 { + static Scanner sc; + static int[] dp; + static int N; + + public static void main(String[] args) { + sc = new Scanner(System.in); + N = sc.nextInt(); // 주어진 정수 + dp = new int[1001]; + dp[1] = 1; + dp[2] = 2; + + for (int idx = 3; idx <= N; idx++) { + int curCount = (dp[idx - 1] + dp[idx - 2]) % 10007; + dp[idx] = curCount; + } + + System.out.println(dp[N]); + } + +} From 98aa9b75299b6aabd60bee1f5bc1c3cbfec40162 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 24 Mar 2025 01:13:56 +0900 Subject: [PATCH 159/177] =?UTF-8?q?[11727=202xn=ED=83=80=EC=9D=BC=EB=A7=81?= =?UTF-8?q?2=20-=2025.03.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...355\203\200\354\235\274\353\247\2012.java" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11727_2xn\355\203\200\354\235\274\353\247\2012.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11727_2xn\355\203\200\354\235\274\353\247\2012.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11727_2xn\355\203\200\354\235\274\353\247\2012.java" new file mode 100644 index 0000000..ca90e0e --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11727_2xn\355\203\200\354\235\274\353\247\2012.java" @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class BOJ_11727_2xn타일링2 { + static Scanner sc; + static int[] dp; + static int N; + + public static void main(String[] args) { + sc = new Scanner(System.in); + N = sc.nextInt(); // 주어진 정수 + dp = new int[1001]; + dp[1] = 1; + dp[2] = 3; + + for (int idx = 3; idx <= N; idx++) { + int curCount = (dp[idx - 1] + dp[idx - 2] * 2) % 10007; + dp[idx] = curCount; + } + + System.out.println(dp[N]); + } + +} From cb059506fe2de66a96d9eea76ca588641d5efc69 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 24 Mar 2025 01:14:22 +0900 Subject: [PATCH 160/177] =?UTF-8?q?[11052=20=EC=B9=B4=EB=93=9C=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B0=20-=2025.03.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\247\244\355\225\230\352\270\260.java" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260.java" new file mode 100644 index 0000000..f5e5d63 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_11052_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\260.java" @@ -0,0 +1,36 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_11052_카드구매하기 { + static BufferedReader br; + static StringTokenizer st; + static int[] cards, dp; + + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); // 구매하려 하는 카드 개수 + cards = new int[N + 1]; + dp = new int[N + 1]; + + st = new StringTokenizer(br.readLine()); + for (int idx = 1; idx <= N; idx++) { + int inputNum = Integer.parseInt(st.nextToken()); + cards[idx] = inputNum; + dp[idx] = inputNum; + } + + dp[1] = cards[1]; + + for (int idx = 2; idx <= N; idx++) { + for (int i = 1; i <= idx / 2; i++) { + dp[idx] = Math.max(dp[idx - i] + dp[i], dp[idx]); + + } + } + + System.out.println(dp[N]); + } + +} From eb079a66e32969209371798a10b43f08f61bdee3 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 24 Mar 2025 01:15:04 +0900 Subject: [PATCH 161/177] =?UTF-8?q?[16194=20=EC=B9=B4=EB=93=9C=EA=B5=AC?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B02=20-=2025.03.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...353\247\244\355\225\230\352\270\2602.java" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602.java" new file mode 100644 index 0000000..46caa2f --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_16194_\354\271\264\353\223\234\352\265\254\353\247\244\355\225\230\352\270\2602.java" @@ -0,0 +1,36 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_16194_카드구매하기2 { + static BufferedReader br; + static StringTokenizer st; + static int[] cards, dp; + + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); // 구매하려 하는 카드 개수 + cards = new int[N + 1]; + dp = new int[N + 1]; + + st = new StringTokenizer(br.readLine()); + for (int idx = 1; idx <= N; idx++) { + int inputNum = Integer.parseInt(st.nextToken()); + cards[idx] = inputNum; + dp[idx] = inputNum; + } + + dp[1] = cards[1]; + + for (int idx = 2; idx <= N; idx++) { + for (int i = 1; i <= idx / 2; i++) { + dp[idx] = Math.min(dp[idx - i] + dp[i], dp[idx]); + + } + } + + System.out.println(dp[N]); + } + +} From e37ef31084a7eb4751bd1a8957bc996ef6c7c5e5 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 24 Mar 2025 01:15:29 +0900 Subject: [PATCH 162/177] =?UTF-8?q?[15990=20123=EB=8D=94=ED=95=98=EA=B8=B0?= =?UTF-8?q?5=20-=2025.03.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...353\215\224\355\225\230\352\270\2605.java" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15990_123\353\215\224\355\225\230\352\270\2605.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15990_123\353\215\224\355\225\230\352\270\2605.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15990_123\353\215\224\355\225\230\352\270\2605.java" new file mode 100644 index 0000000..77cb2d0 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_15990_123\353\215\224\355\225\230\352\270\2605.java" @@ -0,0 +1,38 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class BOJ_15990_123더하기5 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + int T = Integer.parseInt(br.readLine()); + int maxNum = 0; + int[] input = new int[T]; + long[][] dp = new long[100_001][4]; + + dp[1][1] = 1; + dp[2][2] = 1; + dp[3][1] = 1; // 합이 3으로 만드는 경우 중에 마지막으로 더해지는 수가 1인 경우의 수 + dp[3][2] = 1; + dp[3][3] = 1; + + for (int tc = 0; tc < T; tc++) { + input[tc] = Integer.parseInt(br.readLine()); + maxNum = Math.max(maxNum, input[tc]); + } + + // 마지막으로 더하는 수를 1 or 2 or 3으로 나누어 생각. + for (int i = 4; i <= maxNum; i++) { + dp[i][1] = (dp[i - 1][2] + dp[i - 1][3]) % 1_000_000_009; + dp[i][2] = (dp[i - 2][1] + dp[i - 2][3]) % 1_000_000_009; + dp[i][3] = (dp[i - 3][1] + dp[i - 3][2]) % 1_000_000_009; + } + + for (int inputNum : input) { + sb.append((dp[inputNum][1] + dp[inputNum][2] + dp[inputNum][3]) % 1_000_000_009).append('\n'); + } + System.out.println(sb); + } + +} From 8e701abc09a0cfd88eb7639b16efd8a2ba926971 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 24 Mar 2025 01:15:59 +0900 Subject: [PATCH 163/177] =?UTF-8?q?[10844=20=EC=89=AC=EC=9A=B4=EA=B3=84?= =?UTF-8?q?=EB=8B=A8=EC=88=98=20-=2025.03.24]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\352\263\204\353\213\250\354\210\230.java" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.java" diff --git "a/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.java" "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.java" new file mode 100644 index 0000000..fef9280 --- /dev/null +++ "b/3\354\233\224 3\354\243\274\354\260\250/HeeGyeong/BOJ_10844_\354\211\254\354\232\264\352\263\204\353\213\250\354\210\230.java" @@ -0,0 +1,31 @@ +import java.util.Scanner; + +public class BOJ_10844_쉬운계단수 { + static Scanner sc; + static int[][] dp; + static int N; + + public static void main(String[] args) { + sc = new Scanner(System.in); + N = sc.nextInt(); // 정수의 길이 + dp = new int[101][10]; + for (int n = 1; n <= 9; n++) { + dp[1][n] = 1; //정수의 길이가 1이고 n으로 끝나는 경우의 수 + } + + for (int i = 2; i <= N; i++) { + dp[i][0] = dp[i - 1][1]; + for (int j = 1; j <= 8; j++) { + dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1]) % 1_000_000_000; + } + dp[i][9] = dp[i - 1][8]; + } + + long result = 0; + for (int last = 0; last <= 9; last++) { + result += dp[N][last]; + } + System.out.println(result % 1_000_000_000); + } + +} From 4c2fedd4fbd8fa59ff49e80c02424b0847a4c465 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Tue, 25 Mar 2025 23:45:51 +0900 Subject: [PATCH 164/177] =?UTF-8?q?[2193=20=EC=9D=B4=EC=B9=9C=EC=88=98=20-?= =?UTF-8?q?=2025.03.25]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_2193.java" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193.java" new file mode 100644 index 0000000..1923f3f --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193.java" @@ -0,0 +1,32 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_2193 { + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + long[][] dp = new long[91][3]; + + dp[1][0] = 0; + dp[1][1] = 1; + dp[1][2] = 1; + + for(int i=2;i<91;i++) { + dp[i][0] = dp[i-1][2]; + dp[i][1] = dp[i-1][0]; + dp[i][2] = dp[i][0] +dp[i][1]; + } + + System.out.println(dp[n][2]); + + } + + +} From c7afb5546d33735eec58950fbad6adfc694c7109 Mon Sep 17 00:00:00 2001 From: yurichoi0510 Date: Wed, 26 Mar 2025 00:16:11 +0900 Subject: [PATCH 165/177] =?UTF-8?q?[11053=20=EA=B0=80=EC=9E=A5=20=EA=B8=B4?= =?UTF-8?q?=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=97=B4=20-=202.=200.=202.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_11053.java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_11053.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_11053.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_11053.java" new file mode 100644 index 0000000..d0c976e --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_11053.java" @@ -0,0 +1,40 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_11053 { + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + int[] arr =new int[1001]; + StringTokenizer st = new StringTokenizer(br.readLine().trim()); + for(int i=1; i<=n;i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + int[] dp = new int[1001]; + + dp[1] = 1; + int nowLength; + int result = 1; + + for(int i=2;i<=n;i++) { + nowLength = 0; + for(int j =1; j Date: Wed, 26 Mar 2025 00:33:26 +0900 Subject: [PATCH 166/177] =?UTF-8?q?[14002=20=EA=B0=80=EC=9E=A5=20=EA=B8=B4?= =?UTF-8?q?=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=97=B44=20-=2025.03.26]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yuri/BOJ_14002.java" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14002.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14002.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14002.java" new file mode 100644 index 0000000..2e5cc5c --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14002.java" @@ -0,0 +1,59 @@ +package test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayDeque; +import java.util.Stack; +import java.util.StringTokenizer; + +public class BOJ_14002 { + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + int[] arr =new int[1001]; + StringTokenizer st = new StringTokenizer(br.readLine().trim()); + for(int i=1; i<=n;i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + int[] dp = new int[1001]; + int[] from = new int[1001]; + ArrayDeque resultList = new ArrayDeque(); + dp[1] = 1; + int nowLength; + int result = 1; + int resultLocation = 1; + + for(int i=2;i<=n;i++) { + nowLength = 0; + for(int j =1; jresult) { + result= dp[i]; + resultLocation=i; + } + } + + System.out.println(result); + + int nowLocation =resultLocation; + for(int i=1; i<=result;i++) { + resultList.offer(arr[nowLocation]); + nowLocation = from[nowLocation]; + } + + for(int i=1; i<=result;i++) { + System.out.print(resultList.pollLast()+" "); + } + + } + + +} From dcf0beae4f4a57d48dc4dda9ac9c73e1d6ef83bd Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 30 Mar 2025 18:28:44 +0900 Subject: [PATCH 167/177] =?UTF-8?q?[2193=20=EC=9D=B4=EC=B9=9C=EC=88=98=20-?= =?UTF-8?q?=2025.03.30]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\264\354\271\234\354\210\230.java" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" new file mode 100644 index 0000000..0af0192 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" @@ -0,0 +1,27 @@ +import java.util.Scanner; + +// dp 자료형을 int[][]로 설정하면 N=47 이상부터 오버플로 발생함. +public class BOJ_2193_이친수 { + static Scanner sc; + static long[][] dp; + static int N; + + public static void main(String[] args) { + sc = new Scanner(System.in); + N = sc.nextInt(); // N자리 + dp = new long[91][2]; // 마지막 자리 숫자 0 or 1에 따른 경우의 수 + dp[1][1] = 1; + dp[2][0] = 1; + dp[3][0] = 1; + dp[3][1] = 1; + + for (int idx = 4; idx <= N; idx++) { + dp[idx][0] = dp[idx - 1][0] + dp[idx - 1][1]; + dp[idx][1] = dp[idx - 1][0]; + + } + + System.out.println(dp[N][0] + dp[N][1]); + } + +} From 7dc0a3f17af796e876658df97c3b967e6faa9e58 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 30 Mar 2025 18:29:12 +0900 Subject: [PATCH 168/177] =?UTF-8?q?[11053=20=EA=B0=80=EC=9E=A5=20=EA=B8=B4?= =?UTF-8?q?=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=97=B4=20-=2025.03.30]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\266\204\354\210\230\354\227\264.java" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_11053_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\264.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_11053_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\264.java" "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_11053_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\264.java" new file mode 100644 index 0000000..39b8468 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_11053_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\264.java" @@ -0,0 +1,34 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_11053_가장긴증가하는부분수열 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + int[] seq = new int[N]; // 주어지는 수열 저장 + int[] dp = new int[N]; // 해당 자리 수로 끝나는 부분수열 중 가장 긴 수열의 길이 + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + seq[idx] = Integer.parseInt(st.nextToken()); + } + + Arrays.fill(dp, 1); // 각 자리 수로 시작하면 수열의 길이 1이므로, 1로 초기화 + + for (int idx = 1; idx < N; idx++) { + for (int prevIdx = 0; prevIdx < idx; prevIdx++) { + if (seq[prevIdx] < seq[idx]) { // 이전의 수보다 그 값이 큰 경우 + dp[idx] = Math.max(dp[idx], dp[prevIdx] + 1); + } + } + } + + Arrays.sort(dp); // 마지막 수로 끝나는 부분집합의 길이가 가장 크다는 보장 없으므로, + // 어떤 수로 끝나든 상관없이 가장 긴 부분집합의 길이 알기 위해 정렬. + + System.out.println(dp[N - 1]); + } + +} From fc968a5cdef6bb82d4af19b7f83fb65688779021 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Sun, 30 Mar 2025 18:29:31 +0900 Subject: [PATCH 169/177] =?UTF-8?q?[14002=20=EA=B0=80=EC=9E=A5=20=EA=B8=B4?= =?UTF-8?q?=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=97=B44=20-=2025.03.30]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...353\266\204\354\210\230\354\227\2644.java" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644.java" "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644.java" new file mode 100644 index 0000000..275216d --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_14002_\352\260\200\354\236\245\352\270\264\354\246\235\352\260\200\355\225\230\353\212\224\353\266\200\353\266\204\354\210\230\354\227\2644.java" @@ -0,0 +1,51 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_14002_가장긴증가하는부분수열4 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + int[] seq = new int[N]; // 주어지는 수열 저장 + int[] dp = new int[N]; // 해당 자리 수로 끝나는 부분수열 중 가장 긴 수열의 길이 + int[] prev = new int[N]; // 직전의 숫자 저장 + + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + seq[idx] = Integer.parseInt(st.nextToken()); // 입력 받음 + } + + for (int idx = 0; idx < N; idx++) { + dp[idx] = 1; // 각 자리 수로 시작하면 수열의 길이 1이므로, 1로 초기화 + prev[idx] = -1; // 직전의 인덱스를 -1로 초기화 + } + + int maxLength = 1, maxIdx = 0; + for (int idx = 1; idx < N; idx++) { + for (int prevIdx = 0; prevIdx < idx; prevIdx++) { + if (seq[prevIdx] < seq[idx] && dp[idx] < dp[prevIdx] + 1) { // 이전의 수보다 그 값이 크고, 부분집합의 길이가 더 긴 경우 + dp[idx] = dp[prevIdx] + 1; + prev[idx] = prevIdx; + } + } + + // 마지막 수로 끝나는 부분집합의 길이가 가장 크다는 보장 없으므로, 가장 긴 부분집합의 길이 알기 위함. + if (dp[idx] > maxLength) { + maxLength = dp[idx]; + maxIdx = idx; + } + } + + System.out.println(dp[maxIdx]); + StringBuilder sb = new StringBuilder(); + + int seqIdx = maxIdx; + for (int count = 0; count < dp[maxIdx]; count++) { + sb.insert(0, seq[seqIdx] + " "); + seqIdx = prev[seqIdx]; + } + System.out.println(sb); + } + +} From 5240098a33063042c75030424733fe10d0f97e03 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 31 Mar 2025 00:12:19 +0900 Subject: [PATCH 170/177] =?UTF-8?q?[1912=20=EC=97=B0=EC=86=8D=ED=95=A9=20-?= =?UTF-8?q?=2025.03.30]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\227\260\354\206\215\355\225\251.java" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" new file mode 100644 index 0000000..f784af8 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" @@ -0,0 +1,35 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_1912_연속합 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + int[] seq = new int[N]; // 주어지는 수열 저장 + int[] dp = new int[N]; // 해당 자리 수를 포함하는 부분수열 중 그 요소의 합의 최댓값 + + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int idx = 0; idx < N; idx++) { + int curNum = Integer.parseInt(st.nextToken()); + seq[idx] = curNum; + dp[idx] = curNum; + + } + + for (int idx = 1; idx < N; idx++) { + // (이전의 수를 포함하는 합 + 현재 수) 가 (현재 수를 포함하는 합)보다 큰 경우 + if (dp[idx] < dp[idx - 1] + seq[idx]) { + dp[idx] = dp[idx - 1] + seq[idx]; + } + } + + Arrays.sort(dp); // 마지막 수로 끝나는 부분집합의 합이 가장 크다는 보장 없으므로, + // 어떤 수로 끝나든 상관없이 가장 높은 부분집합의 합 알기 위해 오름차순 정렬. + + System.out.println(dp[N - 1]); + } + +} From bf6686fe2c35ca740a48bc9574421f53a8dcc75e Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 31 Mar 2025 00:12:46 +0900 Subject: [PATCH 171/177] =?UTF-8?q?[1699=20=EC=A0=9C=EA=B3=B1=EC=88=98?= =?UTF-8?q?=EC=9D=98=20=ED=95=A9=20-=2025.03.30]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\210\230\354\235\230\355\225\251.java" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" new file mode 100644 index 0000000..fb88539 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" @@ -0,0 +1,29 @@ +import java.util.Scanner; + +public class BOJ_1699_제곱수의합 { + static Scanner sc; + static int[] dp; + static int N; + + public static void main(String[] args) { + sc = new Scanner(System.in); + N = sc.nextInt(); // 주어진 자연수 + dp = new int[N + 1]; // 해당 수를 표현할 수 있는 최소 제곱수 항 + + // 가능한 제곱수항의 최대값인 자기 자신으로 초기화 + for (int i = 1; i <= N; i++) { + dp[i] = i; + } + + for (int idx = 0; idx <= N; idx++) { + for (int n = 1; idx + (n * n) <= N; n++) { // (현재 수 + 제곱수)가 N이하인 경우만 확인 + if (idx + n * n <= N && dp[idx + n * n] > dp[idx] + 1) { + dp[idx + n * n] = dp[idx] + 1; + } + } + } + + System.out.println(dp[N]); + } + +} From 13fc317de0f0567df71d146956d018e3faa4b884 Mon Sep 17 00:00:00 2001 From: HeeGyeong01 Date: Mon, 31 Mar 2025 00:12:59 +0900 Subject: [PATCH 172/177] =?UTF-8?q?[2225=20=ED=95=A9=EB=B6=84=ED=95=B4=20-?= =?UTF-8?q?=2025.03.30]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\225\251\353\266\204\355\225\264.java" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" new file mode 100644 index 0000000..b4c328f --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/HeeGyeong/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" @@ -0,0 +1,32 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_2225_합분해 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int K = Integer.parseInt(st.nextToken()); + + int[][] dp = new int[N + 1][K + 1]; // 정수 k개를 더해서 그 합이 N이 되는 경우의 수 + + // 자기 자신 1번 더한 경우 + for (int idx = 1; idx <= N; idx++) { + dp[idx][1] = 1; + } + for (int k = 1; k <= K; k++) { // 합이 0일때 모두 1로 초기화 + dp[0][k] = 1; + } + + for (int k = 2; k <= K; k++) { // k개 + for (int n = 1; n <= N; n++) { // 합 n + dp[n][k] = (dp[n][k - 1] + dp[n - 1][k]) % 1_000_000_000; + } + } + + System.out.println(dp[N][K]); + } + +} From 74082da4760c934287a74f8a6746d08b671eaa64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B4=89=ED=98=84=EC=A7=84?= Date: Mon, 31 Mar 2025 13:21:27 +0900 Subject: [PATCH 173/177] =?UTF-8?q?[2193=20=EC=9D=B4=EC=B9=9C=EC=88=98=20-?= =?UTF-8?q?=2025.03.31]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\264\354\271\234\354\210\230.java" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" new file mode 100644 index 0000000..fc10dba --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2193_\354\235\264\354\271\234\354\210\230.java" @@ -0,0 +1,30 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.StringTokenizer; + +public class BOJ_2193_이친수 { + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + long[][] dp = new long[91][3]; + + dp[1][0] = 0; + dp[1][1] = 1; + dp[1][2] = 1; + + for(int i=2;i<91;i++) { + dp[i][0] = dp[i-1][2]; + dp[i][1] = dp[i-1][0]; + dp[i][2] = dp[i][0] +dp[i][1]; + } + + System.out.println(dp[n][2]); + + } + + +} From 588802642f356feb183310b5ca5bbb90f4a7ed86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B4=89=ED=98=84=EC=A7=84?= Date: Mon, 31 Mar 2025 13:26:49 +0900 Subject: [PATCH 174/177] =?UTF-8?q?[1912=20=EC=97=B0=EC=86=8D=ED=95=A9=20-?= =?UTF-8?q?=2025.03.31]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\227\260\354\206\215\355\225\251.java" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" new file mode 100644 index 0000000..b957c51 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1912_\354\227\260\354\206\215\355\225\251.java" @@ -0,0 +1,29 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_1912_연속합 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int n = Integer.parseInt(br.readLine().trim()); + int[] dp = new int[100000]; + + + st = new StringTokenizer(br.readLine().trim()); + + dp[0] = Integer.parseInt(st.nextToken()); + int max=dp[0]; + int number; + for(int i=1; i Date: Mon, 31 Mar 2025 13:28:21 +0900 Subject: [PATCH 175/177] =?UTF-8?q?[1699=20=EC=A0=9C=EA=B3=B1=EC=88=98?= =?UTF-8?q?=EC=9D=98=ED=95=A9=20-=2025.03.31]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\210\230\354\235\230\355\225\251.java" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" new file mode 100644 index 0000000..3bc6931 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_1699_\354\240\234\352\263\261\354\210\230\354\235\230\355\225\251.java" @@ -0,0 +1,41 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +// +//public class Main { +// +// public static void main(String[] args) throws IOException { +// BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); +// +// int n = Integer.parseInt(br.readLine().trim()); +// int[] dp = new int[100001]; +// +// +// for(int i=1; i<=n;i++) { +// for(int j = 1; j*j<=i; j++) { +// dp[i]= Math.min(dp[i-1]+1, 1+dp[i-j*j]); +// } +// } +// +// System.out.println(dp[n]); +// } +//} + +public class BOJ_1699_제곱수의합 { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + int n = Integer.parseInt(br.readLine().trim()); + int[] dp = new int[n + 1]; + + for (int i = 1; i <= n; i++) { + dp[i] = i; // 최악의 경우: 모두 1^2 + for (int j = 1; j * j <= i; j++) { + dp[i] = Math.min(dp[i], dp[i - j * j] + 1); + } + } + + System.out.println(dp[n]); + } +} From 72bc022aef60334ef7f327aa9f855a10a2173d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B4=89=ED=98=84=EC=A7=84?= Date: Mon, 31 Mar 2025 13:29:44 +0900 Subject: [PATCH 176/177] =?UTF-8?q?[14501=20=ED=87=B4=EC=82=AC=20-=2025.03?= =?UTF-8?q?.31]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BOJ_14501_\355\207\264\354\202\254.java" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14501_\355\207\264\354\202\254.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14501_\355\207\264\354\202\254.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14501_\355\207\264\354\202\254.java" new file mode 100644 index 0000000..8c3d642 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_14501_\355\207\264\354\202\254.java" @@ -0,0 +1,34 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_14501_퇴사 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int N = Integer.parseInt(br.readLine()); + int[] t = new int[N + 2]; // 상담 기간 + int[] p = new int[N + 2]; // 상담 수익 + int[] dp = new int[N + 2]; // i일까지 얻을 수 있는 최대 수익 + + for (int i = 1; i <= N; i++) { + st = new StringTokenizer(br.readLine()); + t[i] = Integer.parseInt(st.nextToken()); + p[i] = Integer.parseInt(st.nextToken()); + } + + for (int i = 1; i <= N + 1; i++) { + // 이전까지의 최대 수익을 이어받기 + dp[i] = Math.max(dp[i], dp[i - 1]); + + // 상담을 선택할 수 있는 경우 + if (i + t[i] <= N + 1) { + dp[i + t[i]] = Math.max(dp[i + t[i]], dp[i] + p[i]); + } + } + + System.out.println(dp[N + 1]); + } +} From 8fefed7ff18c02fadf826de54c28424ba37a30c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B4=89=ED=98=84=EC=A7=84?= Date: Mon, 31 Mar 2025 13:32:17 +0900 Subject: [PATCH 177/177] =?UTF-8?q?[2225=20=ED=95=A9=EB=B6=84=ED=95=B4=20-?= =?UTF-8?q?=2025.03.31]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\225\251\353\266\204\355\225\264.java" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" diff --git "a/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" new file mode 100644 index 0000000..97f0995 --- /dev/null +++ "b/3\354\233\224 4\354\243\274\354\260\250/Yuri/BOJ_2225_\355\225\251\353\266\204\355\225\264.java" @@ -0,0 +1,36 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class BOJ_2225_합분해 { + static final int MOD = 1_000_000_000; + static int N, K; + static int[][] dp; + + public static void main(String[] args) throws NumberFormatException, IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine().trim()); + + N = Integer.parseInt(st.nextToken()); // 만들 수 + K = Integer.parseInt(st.nextToken()); // 정수 개수 + + dp = new int[K + 1][N + 1]; + + // 초기 조건 설정 + for (int i = 0; i <= K; i++) { + dp[i][0] = 1; // 0을 만드는 방법은 항상 1개 (모든 수가 0일 때) + } + + for (int i = 1; i <= K; i++) { // i개 수로 + for (int j = 1; j <= N; j++) { // j를 만드는 방법 + for (int l = 0; l <= j; l++) { + dp[i][j] = (dp[i][j] + dp[i - 1][j - l]) % MOD; + } + } + } + + System.out.println(dp[K][N]); + } +} +