From b74bd8466c3823bcf71ee2e46801b2cf98a7cb41 Mon Sep 17 00:00:00 2001 From: naryeong-ko Date: Wed, 4 May 2022 19:36:43 +0900 Subject: [PATCH 1/3] 220504_solve : P1620_ko --- 0503/BOJ/P1620/P1620_ko.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 0503/BOJ/P1620/P1620_ko.java diff --git a/0503/BOJ/P1620/P1620_ko.java b/0503/BOJ/P1620/P1620_ko.java new file mode 100644 index 0000000..7db87c8 --- /dev/null +++ b/0503/BOJ/P1620/P1620_ko.java @@ -0,0 +1,29 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; + +public class Main_P1620 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); // 포켓몬 수 + int M = sc.nextInt(); // 문제 수 + Map nameMap = new HashMap<>(); // 번호에 해당하는 스트링 + Map numMap = new HashMap<>(); // 이름에 해당하는 번호 + for (int i = 1; i <= N; i++) { + String name = sc.next(); + nameMap.put(String.valueOf(i), name); + numMap.put(name, String.valueOf(i)); + } + + for (int i = 0; i < M; i++) { + String q = sc.next(); + if (nameMap.containsKey(q)) // 번호면 이름 이름이면 번호 + System.out.println(nameMap.get(q)); + else + System.out.println(numMap.get(q)); + } + + } + +} \ No newline at end of file From 49185ada5a4dbcd544271ad08c6f9d8db6026fb9 Mon Sep 17 00:00:00 2001 From: naryeong-ko Date: Wed, 4 May 2022 19:36:56 +0900 Subject: [PATCH 2/3] 220504_solve : P1697_ko --- 0503/BOJ/P1697/P1697_ko.java | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 0503/BOJ/P1697/P1697_ko.java diff --git a/0503/BOJ/P1697/P1697_ko.java b/0503/BOJ/P1697/P1697_ko.java new file mode 100644 index 0000000..f12d143 --- /dev/null +++ b/0503/BOJ/P1697/P1697_ko.java @@ -0,0 +1,52 @@ +import java.util.LinkedList; +import java.util.Queue; +import java.util.Scanner; + +public class Main_P1697 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); // 수빈 + int K = sc.nextInt(); // 동생 + System.out.print(bfs(N, K)); + } + + static int bfs(int N, int K) { + boolean[] visit = new boolean[100001]; // 0~100000 갈 수 있음 + Queue q = new LinkedList<>(); + int next, now; + int ret = 0; // 0초로 초기화 + + q.add(N); // 시작 위치 방문 + visit[N] = true; + while (N != K) { // 첫 값 같은 자리인지 확인 + int size = q.size(); + for (int i = 0; i < size; i++) { // 사이즈로 묶기 + now = q.poll(); + for (int j = 0; j < 3; j++) { + if (j == 0) + next = now - 1; + else if (j == 1) + next = now + 1; + else + next = now * 2; + + if (next < 0 || next > 100000 || visit[next]) // 다음 값 갈 수 있는지 + continue; + + if (next == K) // 찾았다면 끝 + return ++ret; // 다음 번에 갈 수 있으므로 +1 + + q.add(next); + visit[next] = true; // 갈 수 있으면 방문처리 + } + } + + ret++; // 깊이 + } + + return ret; + + } + +} \ No newline at end of file From 01b27a510243d6a4b975137eb89d0298dc872735 Mon Sep 17 00:00:00 2001 From: naryeong-ko Date: Wed, 4 May 2022 19:37:06 +0900 Subject: [PATCH 3/3] 220504_solve : P1676_ko --- 0503/BOJ/P1676/P1676_ko.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 0503/BOJ/P1676/P1676_ko.java diff --git a/0503/BOJ/P1676/P1676_ko.java b/0503/BOJ/P1676/P1676_ko.java new file mode 100644 index 0000000..e79d8d4 --- /dev/null +++ b/0503/BOJ/P1676/P1676_ko.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +public class Main_P1676 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); // 숫자 입력 + int cnt = 0; + int np; + for (int i = n; i >= 5; i--) { // 5개수로 0개수 세기 + np = i; + while (np % 5 == 0) { + cnt++; + np /= 5; + } + } + System.out.print(cnt); + } + +}