코딩 테스트 (6) 썸네일형 리스트형 [SWEA : JAVA] 1251 하나로 (MST, Prim 알고리즘) https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV15StKqAQkCFAYD SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 정리 모든 섬을 관통할 수 있는 해저 터널 연결 해저 터널은 두 섬을 선분으로 연결하며, 두 해저터널이 교차하더라도 연결되지 않은것이다. 환경 부담금 : 환경 부담 세율(E) * 해저 터널 길이(L) 의 제곱 총 환경 부담금을 최소로 하기 풀이 총 환경 부담금을 최소로 하기 위해서 하나의 섬에서 다른 섬으로 선분을 연결할 때마다 매번 가장 가까운 섬과 연결해야 한다. 모든 섬을 연결해야 하므로 MS.. [백준 : JAVA] 1753 최단경로 풀이 다익스트라(Dijkstra) 알고리즘을 활용하여 최단 경로를 구하는 코드입니다. 다익스트라 알고리즘은 시작 노드에서부터 다른 모든 노드까지의 최단 경로를 찾는 데 사용됩니다. public class Main { // 간선 정보를 저장하기 위한 클래스 static class Edge implements Comparable{ int end, weight; public Edge(int end, int weight){ this.end = end; this.weight = weight; } // 가중치 값에 따라 정렬 @Override public int compareTo(Edge o) { return weight - o.weight; } } private static final BufferedReader .. [백준 : JAVA] 1929 소수 구하기 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class silver3_1929 { static boolean[] primeNum; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(.. [백준 : JAVA] 4158 CD public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true){ StringTokenizer st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken()); int b = Integer.parseInt(st.nextToken()); if(a==0&&b==0)break; int cnt = 0; HashSet list = new HashSet(); int[] arr = new int[a]; f.. [백준 : JAVA] 2161 카드1 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Card1 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int j =0; StringBuilder sb= new StringBuilder(); List list.. [백준 : JAVA] 9093 단어 뒤집기 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); // nextInt() 다음 enter 값이 남아서 다음 //nextLine()시 공백이 읽혀버림 for (int i = 0; i 이전 1 다음