[백준] 15649번 N과 M (1) import java.util.Scanner; public class Main { static StringBuilder sb = new StringBuilder(); static int N, M; static int[] select; static void rec_func(int k) { if (k == M + 1) { for (int i = 1; i 공부기록/백준 2023.09.27
[백준] 2775번 부녀회장이 될테야 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner kb = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int num = kb.nextInt(); int[][] arr = new int [15][15]; for(int i=1; i 공부기록/백준 2023.09.27
[백준] 1110번 더하기 사이클 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int num = kb.nextInt(); int originalNum = num; int count = 0; do { int tensDigit = num / 10; int onesDigit = num % 10; int sum = tensDigit + onesDigit; num = (onesDigit * 10) + (sum % 10); count++; } while (num != originalNum); System.out.print(count); } } 공부기록/백준 2023.09.27
[프로그래머스] 네트워크 class Solution { static boolean[] visit; static int num; static int[][] comInfo; public int solution(int n, int[][] computers) { int answer = 0; visit = new boolean[n]; num = n; comInfo = computers; for(int i=0; i< num; i++){ if(!visit[i]){ dfs(i); answer++; } } return answer; } static void dfs(int x){ visit[x] = true; for(int i=0; i 공부기록/프로그래머스 2023.09.24
[백준] 4963번 섬의 개수 import java.util.Scanner; public class Main { static int w, h; static int[][] a; static boolean[][] visit; static int[][] dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; static int count; static void DFS(int x, int y) { visit[x][y] = true; for (int i = 0; i = h || ny >= w) contin.. 공부기록/백준 2023.09.24
[백준] 2667번 단지번호붙이기 import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { static String[] a; static int n; static boolean[][] visit; static ArrayList group; static int groupCount; static int[][] dir = {{-1,0},{1,0},{0,-1},{0,1}}; static void DFS(int x, int y) { groupCount++; visit[x][y] = true; for(int i=0; i 공부기록/백준 2023.09.24
[백준] 1260번 DFS와 BFS import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static ArrayList[] adj; static boolean[] visit; static StringBuilder sb = new StringBuilder(); static void dfs(int x) { visit[x] = true; sb.append(x).append(' '); for(int y: adj[x]) { if(visit[y]) continue; dfs(y); } } static void bfs(int x).. 공부기록/백준 2023.09.23
[백준] 1076번 저항 import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner kb = new Scanner(System.in); String color1 = kb.next(); String color2 = kb.next(); String color3 = kb.next(); ArrayList list = new ArrayList(); list.add("black"); list.add("brown"); list.add("red"); list.add("orange"); list.add("yellow"); list.add("green"); list.add("blue");.. 공부기록/백준 2023.09.22
[프로그래머스] 예산 import java.util.*; class Solution { public int solution(int[] d, int budget) { int answer = 0; Arrays.sort(d); for(int i=0; i 공부기록/프로그래머스 2023.09.21
[프로그래머스] 두 개 뽑아서 더하기 import java.util.*; class Solution { public ArrayList solution(int[] numbers) { ArrayList list = new ArrayList(); for(int i=0; i 공부기록/프로그래머스 2023.09.17