From 6ee919a4eb3efb81374d6df00ccd35b3a22de1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B8=B0=EC=B0=AC?= <140886562+TearofCoding@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:07:00 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[solved]=20=EC=A2=8B=EC=9D=80=EC=88=98?= =?UTF-8?q?=EC=97=B4.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KimKiChan/boj/MessiGimossi.java | 54 ++++++++++++++++++ ...\353\221\220\353\217\231\354\240\204.java" | 2 + ...\354\235\200\354\210\230\354\227\264.java" | 57 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 KimKiChan/boj/MessiGimossi.java create mode 100644 "KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" diff --git a/KimKiChan/boj/MessiGimossi.java b/KimKiChan/boj/MessiGimossi.java new file mode 100644 index 00000000..36e357ea --- /dev/null +++ b/KimKiChan/boj/MessiGimossi.java @@ -0,0 +1,54 @@ +package boj; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class MessiGimossi { + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int m = Integer.parseInt(br.readLine()); + + ArrayList Messi = new ArrayList<>(); // Messi의 길이 + Messi.add(6); // "Messi " + Messi.add(14);// "Gimossi " + String str = " Messi Gimossi "; + if(m <= 14) { + if(str.charAt(m) == ' ') { + System.out.println("Messi Messi Gimossi"); + }else { + System.out.println(str.charAt(m)); + } + }else { + while(true) { + if(Messi.get(Messi.size()-1) > m) break; + + Messi.add(Messi.get(Messi.size()-1) + Messi.get(Messi.size()-2)); + } + m -= Messi.get(Messi.size()-2); + int index = Messi.size()-3; + // m은 Messi[index] 어딘가에 있다 + + //Messi Gimmossi까지 뺀다 + while(index >= 2) { + if(m < 14) break; + + if(m <= Messi.get(index) && m > Messi.get(index-1)) { + m -= Messi.get(index-1); + index-=2; + }else if(m <= Messi.get(index-1)) { + index-=1; + } + } + + + if(str.charAt(m) == ' ') { + System.out.println("Messi Messi Gimossi"); + }else { + System.out.println(str.charAt(m)); + } + + } + + } +} diff --git "a/KimKiChan/boj/\353\221\220\353\217\231\354\240\204.java" "b/KimKiChan/boj/\353\221\220\353\217\231\354\240\204.java" index 55fbc184..68ee916d 100644 --- "a/KimKiChan/boj/\353\221\220\353\217\231\354\240\204.java" +++ "b/KimKiChan/boj/\353\221\220\353\217\231\354\240\204.java" @@ -1,3 +1,5 @@ +package boj; + import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayDeque; diff --git "a/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" "b/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" new file mode 100644 index 00000000..7e1da61f --- /dev/null +++ "b/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" @@ -0,0 +1,57 @@ +package boj; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Arrays; + +public class 좋은수열 { + private static int[] arr; + private static int n; + private static boolean solved; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + n = Integer.parseInt(br.readLine()); + + arr = new int[n+1]; // 수열 + solved = false; + sol(1); + } + + private static void sol(int index) { + if(solved) return; + if(index == n+1) { + solved = true; + StringBuilder sb = new StringBuilder(); + for(int i = 1; i < arr.length; i++) { + sb.append(arr[i]); + } + System.out.println(sb); + return; + } + for(int i = 1; i <= 3; i++) { + arr[index] = i; + //부분수열 체크 true + if(check(index)) { + sol(index+1); + } + } + } + + private static boolean check(int index) { // 부분 수열 체크 + int[] left; + int[] right; + + for(int i = 1; i <= index/2; i++) { + left = new int[i]; + right = new int[i]; + for(int j = 0; j < i; j++) { + left[j] = arr[index-j]; + right[j] = arr[index-j-i]; + } + if(Arrays.equals(left, right)) return false; + } + + return true; + } +} From 65649c4d2f713e5a2310a751b332d0d8f00d6663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B8=B0=EC=B0=AC?= <140886562+TearofCoding@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:13:09 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[Update]=20=EC=A2=8B=EC=9D=80=EC=88=98?= =?UTF-8?q?=EC=97=B4.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\242\213\354\235\200\354\210\230\354\227\264.java" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" "b/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" index 7e1da61f..300154a4 100644 --- "a/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" +++ "b/KimKiChan/boj/\354\242\213\354\235\200\354\210\230\354\227\264.java" @@ -46,8 +46,8 @@ private static boolean check(int index) { // 부분 수열 체크 left = new int[i]; right = new int[i]; for(int j = 0; j < i; j++) { - left[j] = arr[index-j]; - right[j] = arr[index-j-i]; + left[j] = arr[index-j-i]; + right[j] = arr[index-j]; } if(Arrays.equals(left, right)) return false; } From 1a8685fee4fa7025d8d5a581c96f9f7ea3053525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B8=B0=EC=B0=AC?= <140886562+TearofCoding@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:14:30 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[solved]=20=EB=8D=94=ED=95=98=EA=B8=B0.java?= 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" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "KimKiChan/boj/\353\215\224\355\225\230\352\270\260.java" diff --git "a/KimKiChan/boj/\353\215\224\355\225\230\352\270\260.java" "b/KimKiChan/boj/\353\215\224\355\225\230\352\270\260.java" new file mode 100644 index 00000000..7bcf1b33 --- /dev/null +++ "b/KimKiChan/boj/\353\215\224\355\225\230\352\270\260.java" @@ -0,0 +1,31 @@ +package boj; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Arrays; + +//15989번 +public class 더하기 { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringBuilder sb = new StringBuilder(); + int[] sum = new int[10001]; // 만드는 경우의 수 + Arrays.fill(sum, 1); + + for(int i = 2; i <= 10000; i++) { + sum[i] += sum[i-2]; + } + for(int i = 3; i <= 10000; i++) { + sum[i] += sum[i-3]; + } + + int t = Integer.parseInt(br.readLine()); + for(int i = 0; i < t; i++) { + int n = Integer.parseInt(br.readLine()); + + sb.append(sum[n]).append("\n"); + } + System.out.println(sb); + + } +} From 9d8df2ae689969d2f40039ee1290782edaee8cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B8=B0=EC=B0=AC?= <140886562+TearofCoding@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:44:28 +0900 Subject: [PATCH 4/4] [solved] boj18430.java --- "KimKiChan/boj/A\354\231\200B2.java" | 46 ++++++++++ ...\352\270\260\352\263\265\355\225\231.java" | 87 +++++++++++++++++++ "KimKiChan/boj/\354\240\200\354\232\270.java" | 43 +++++++++ 3 files changed, 176 insertions(+) create mode 100644 "KimKiChan/boj/A\354\231\200B2.java" create mode 100644 "KimKiChan/boj/\353\254\264\352\270\260\352\263\265\355\225\231.java" create mode 100644 "KimKiChan/boj/\354\240\200\354\232\270.java" diff --git "a/KimKiChan/boj/A\354\231\200B2.java" "b/KimKiChan/boj/A\354\231\200B2.java" new file mode 100644 index 00000000..a1fbac84 --- /dev/null +++ "b/KimKiChan/boj/A\354\231\200B2.java" @@ -0,0 +1,46 @@ +package boj; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Objects; + +//12919번 +public class A와B2 { + static boolean able = false; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + String s = br.readLine(); + String t = br.readLine(); + + sol(s, t); + + if(able) System.out.println(1); + else System.out.println(0); + } + + private static void sol(String s, String t) { + if(able) return; + if(s.length() == t.length()) { +// System.out.println(s); + if(Objects.equals(s, t)) { + able = true; + } + return; + } + + if(t.charAt(t.length()-1) == 'A') { + sol(s, t.substring(0, t.length()-1)); + } + + if(t.charAt(0) == 'B') { + String substr = t.substring(1); + StringBuilder sb = new StringBuilder(substr); + sb.reverse(); + sol(s, sb.toString()); + } + + + } + +} diff --git "a/KimKiChan/boj/\353\254\264\352\270\260\352\263\265\355\225\231.java" "b/KimKiChan/boj/\353\254\264\352\270\260\352\263\265\355\225\231.java" new file mode 100644 index 00000000..c351f8db --- /dev/null +++ "b/KimKiChan/boj/\353\254\264\352\270\260\352\263\265\355\225\231.java" @@ -0,0 +1,87 @@ +package boj; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class 무기공학 { + private static int[][] dxdy = {{1,0},{0,-1},{-1,0},{0,1}};//아래 왼쪽 위 오른쪽 + private static int n; + private static int m; + private static boolean[][] used; + private static int[][] tree; + private static int maxScore; + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine(), " "); + n = Integer.parseInt(st.nextToken()); + m = Integer.parseInt(st.nextToken()); + + tree = new int[n][m]; + for(int i = 0; i < n; i++) { + st = new StringTokenizer(br.readLine(), " "); + for(int j = 0; j < m; j++) { + tree[i][j] = Integer.parseInt(st.nextToken()); + } + } + + used = new boolean[n][m]; + maxScore = 0; + + sol(0, 0, 0); + + System.out.println(maxScore); + + } + + private static void sol(int x, int y, int score) { + if(x==n) { + //최대값 찾기 + if(maxScore < score) { + maxScore = score; + } + return; + } + + if(!used[x][y]) { + //4가지 부메랑 -> 다음 좌표 -> 전부 시도하면 빈칸으로 + for(int dir = 0; dir < 4; dir++) { + int dir2 = (dir+1)%4; + int nx1 = x + dxdy[dir][0]; + int ny1 = y + dxdy[dir][1]; + int nx2 = x + dxdy[dir2][0]; + int ny2 = y + dxdy[dir2][1]; + if(inRange(nx1, ny1) && inRange(nx2, ny2)) { + if(!used[nx1][ny1] && !used[nx2][ny2]) { + used[x][y] = true; + used[nx1][ny1] = true; + used[nx2][ny2] = true; + + if(y+1=0 && y>=0 && x