From ee18978f9fe04bed891e92b900fb100da063f19d Mon Sep 17 00:00:00 2001 From: JunJI97 <102650903+JunJI97@users.noreply.github.com> Date: Mon, 24 Jul 2023 20:37:03 +0900 Subject: [PATCH 1/6] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [지준영] 목표 설정 --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 984b1d1..2b83dd9 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,12 @@ - + + + + + + From 2a1daeb9af90d2fc4d192f918dc32d698de7e596 Mon Sep 17 00:00:00 2001 From: JunJI97 <102650903+JunJI97@users.noreply.github.com> Date: Tue, 25 Jul 2023 00:37:53 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[Solve]=20=EA=B2=BD=EB=A1=9C=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=5F11403=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...41\234\354\260\276\352\270\260_11403.java" | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git "a/src/ji/week1/day1/P_\352\262\275\353\241\234\354\260\276\352\270\260_11403.java" "b/src/ji/week1/day1/P_\352\262\275\353\241\234\354\260\276\352\270\260_11403.java" index f4857c1..71c74ea 100644 --- "a/src/ji/week1/day1/P_\352\262\275\353\241\234\354\260\276\352\270\260_11403.java" +++ "b/src/ji/week1/day1/P_\352\262\275\353\241\234\354\260\276\352\270\260_11403.java" @@ -1,5 +1,54 @@ -package ji.week1.day1; +package com.solve.backjun; -public class P_경로찾기_11403 { +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +public class Main { + public static int[][] map; + public static int N; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); +// BufferedReader br = new BufferedReader(new FileReader("input.txt")); + + // 수업시간에 배웠던 내용 + // readLine()으로 받아올 String 객체를 기본형 타입인 int와 형변환이 안되므로 + // Wrapper Class 사용 (Integer) ==> int 타입 변수를 객체로 포장함 + N = Integer.parseInt(br.readLine()); + map = new int[N][N]; + + for (int h=0; h 키워드 => 플로이드 => 공식 Dab = min(Dab, Dak+Dkb) + for (int k=0; k k -> b) 경로가 없을 때 값이 너무커져서 걸러지는데, + // 여긴 간선이 없을 땐 0이라서 공식을 사용하면 모든 자리에 값이 들어가버려 원인을 찾는 데 시간이 걸렸다. + // 3중 반복문 변수 순서도 주의할 것 (k a b) + + private static void print() { + StringBuilder sb = new StringBuilder(); + for (int h=0; h Date: Tue, 25 Jul 2023 20:55:35 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[Solve]=ED=8C=A9=ED=86=A0=EB=A6=AC=EC=96=BC?= =?UTF-8?q?=200=EC=9D=98=20=EA=B0=9C=EC=88=98=5F1676=20=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...35\230 \352\260\234\354\210\230_1676.java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "src/ji/week1/day1/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" diff --git "a/src/ji/week1/day1/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" "b/src/ji/week1/day1/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" new file mode 100644 index 0000000..44e5aad --- /dev/null +++ "b/src/ji/week1/day1/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" @@ -0,0 +1,40 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + + int answer = factorial(N); + + System.out.println(answer); + + } + + public static int factorial(int N) { + int zero_count = 0; + int sum=1; + + for (int i = N; i > 1; i--) { + sum = sum * i; + // 오버플로우를 방지하는 것이 문제의 핵심 + // 뒤에 0이 있는 숫자는 무엇을 곱해도 0이 유지가 되므로 + // 0을 따로 카운트하고 자리수를 줄인다. + while(sum > 0) { + int temp = sum % 10; + if (temp == 0) { + zero_count++; + sum = sum / 10; + } else { + break; + } + } + if (sum==0) { // 0 곱해지는 현상 방지 (ex : 100!) + sum = 1; + } else if(sum > 1000000) { // 단순 숫자로만 자리수를 채운다면 4자리만큼만 잘라낸다. + sum = sum % 10000; + } + } + return zero_count; + } +} From fbb41412440f1be861cdf6172d27bf27ac386d03 Mon Sep 17 00:00:00 2001 From: JunJI97 <102650903+JunJI97@users.noreply.github.com> Date: Wed, 26 Jul 2023 22:47:05 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=EB=94=94=EB=A0=89=ED=84=B0=EB=A6=AC=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...35\230 \352\260\234\354\210\230_1676.java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "src/ji/week1/day2/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" diff --git "a/src/ji/week1/day2/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" "b/src/ji/week1/day2/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" new file mode 100644 index 0000000..44e5aad --- /dev/null +++ "b/src/ji/week1/day2/P_\355\214\251\355\206\240\353\246\254\354\226\274 0\354\235\230 \352\260\234\354\210\230_1676.java" @@ -0,0 +1,40 @@ +import java.util.Scanner; + +public class Main { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + + int answer = factorial(N); + + System.out.println(answer); + + } + + public static int factorial(int N) { + int zero_count = 0; + int sum=1; + + for (int i = N; i > 1; i--) { + sum = sum * i; + // 오버플로우를 방지하는 것이 문제의 핵심 + // 뒤에 0이 있는 숫자는 무엇을 곱해도 0이 유지가 되므로 + // 0을 따로 카운트하고 자리수를 줄인다. + while(sum > 0) { + int temp = sum % 10; + if (temp == 0) { + zero_count++; + sum = sum / 10; + } else { + break; + } + } + if (sum==0) { // 0 곱해지는 현상 방지 (ex : 100!) + sum = 1; + } else if(sum > 1000000) { // 단순 숫자로만 자리수를 채운다면 4자리만큼만 잘라낸다. + sum = sum % 10000; + } + } + return zero_count; + } +} From 70989613bea04c555e34609173e113da6f6c874e Mon Sep 17 00:00:00 2001 From: JunJI97 <102650903+JunJI97@users.noreply.github.com> Date: Wed, 26 Jul 2023 22:49:16 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[Solve]=20=EB=B6=80=EB=85=80=ED=9A=8C?= =?UTF-8?q?=EC=9E=A5=EC=9D=B4=20=EB=90=A0=ED=85=8C=EC=95=BC=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4(2775)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...220\240\355\205\214\354\225\274_2775.java" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "src/ji/week1/day3/P_\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274_2775.java" diff --git "a/src/ji/week1/day3/P_\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274_2775.java" "b/src/ji/week1/day3/P_\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274_2775.java" new file mode 100644 index 0000000..27f3573 --- /dev/null +++ "b/src/ji/week1/day3/P_\353\266\200\353\205\200\355\232\214\354\236\245\354\235\264 \353\220\240\355\205\214\354\225\274_2775.java" @@ -0,0 +1,44 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class Main { + public static int a; + public static int b; + public static int[] room; + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + + for (int t = 0; t < T; t++) { + a = sc.nextInt(); + b = sc.nextInt(); + room = new int[b]; + for (int i = 0; i < b; i++) { + room[i] = i+1; + } + + recur(1); + System.out.println(room[b-1]); + + } + return; + } + + public static void recur(int floor) { + + for (int i = b-1; i >= 0; i--) { + for (int j = 0; j < i; j++) { + room[i] += room[j]; + } + } + + if (floor == a) { + return; + } + floor++; + recur(floor); + return; + } + +} From 6fe8d4c86a53873d57a0e74d475f06450a1052ce Mon Sep 17 00:00:00 2001 From: JunJI97 <102650903+JunJI97@users.noreply.github.com> Date: Mon, 31 Jul 2023 22:26:06 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[Solve]=EB=B1=80=5F3190=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../day1/week2/day1/P_\353\261\200_3190.java" | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 "src/ji/week1/day1/week2/day1/P_\353\261\200_3190.java" diff --git "a/src/ji/week1/day1/week2/day1/P_\353\261\200_3190.java" "b/src/ji/week1/day1/week2/day1/P_\353\261\200_3190.java" new file mode 100644 index 0000000..237590f --- /dev/null +++ "b/src/ji/week1/day1/week2/day1/P_\353\261\200_3190.java" @@ -0,0 +1,101 @@ +import java.awt.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Queue; +import java.util.StringTokenizer; + +public class Main { + public static int[][] map; + public static int time =0; + public final static int[][] direct = {{0,1},{1,0},{0,-1},{-1,0}}; + public static int now_direct = 0; + public static int now_h = 0; + public static int now_w = 0; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + HashMap hm = new HashMap<>(); + + int N = Integer.parseInt(br.readLine()); + map = new int[N][N]; + // snake queue + Queue queue = new LinkedList<>(); + + int N_apple = Integer.parseInt(br.readLine()); + for (int i = 0; i < N_apple; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int temp_h = Integer.parseInt(st.nextToken()); + int temp_w = Integer.parseInt(st.nextToken()); + map[temp_h-1][temp_w-1] = 2; + } + + int N_angle = Integer.parseInt(br.readLine());; + for (int i = 0; i < N_angle; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int key = Integer.parseInt(st.nextToken()); + String value = st.nextToken(); + hm.put(key, value); + } + + map[0][0] = 1; + queue.add(new Point(0,0)); + + + while (true) { + time++; + int next_h = now_h + direct[now_direct][0]; + int next_w = now_w + direct[now_direct][1]; + if(next_h >= N || next_h < 0 || next_w >= N || next_w < 0) { + break; + } + + if (map[next_h][next_w] == 2) { // 사과 좌표로 이동 + now_h = next_h; + now_w = next_w; + queue.add(new Point(next_h,next_w)); + map[next_h][next_w] = 1; + } else if (map[next_h][next_w] == 1) { // 본인 꼬리 밟음 + break; + } else { // 빈 공간으로 이동 + map[next_h][next_w] = 1; + now_h = next_h; + now_w = next_w; + Point p = queue.poll(); + map[p.x][p.y] = 0; + queue.add(new Point(next_h,next_w)); + } + + if (hm.containsKey(time)) { + String move_to = hm.get(time); + if (move_to.equals("D")) { + now_direct++; + } else { + now_direct--; + } + if (now_direct >= 4) { + now_direct = now_direct % 4; + } + if (now_direct < 0) { + now_direct += 4; + } + } + } + + System.out.println(time); + + } + +// public static void print(int n) { +// StringBuilder sb = new StringBuilder(); +// for (int i=0; i