문제풀이/백준

    백준 2667. 단지번호붙이기 (JAVA) (DFS)

    백준 2667. 단지번호붙이기 (JAVA) (DFS)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; public class Main { static int[][] arr; // 아파트의 위치를 저장할 배열 static boolean[][] visit; // 방문 여부를 입력할 배열 static int[] dr = {-1,1,0,0}; static int[] dc = {0,0,-1,1}; static int cnt ; // 단지내에 존재하는 아파트의 개수 static int N; // 지도의 크기 N*N static ArrayList li..

    백준 1012. 유기농 배추(JAVA) (DFS)

    백준 1012. 유기농 배추(JAVA) (DFS)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[][] arr; static boolean[][]visit; static int M,N,K ; static int[] dr = {-1,0,1,0}; static int[] dc = {0,1,0,-1}; static int cnt = 0; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new Inpu..

    백준 2606. 바이러스 (JAVA)

    백준 2606. 바이러스 (JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int ComCnt, Ssang; static int[][] arr; static boolean[] visit; static int cnt = 0; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st ; ComCnt..

    백준 1932. 정수 삼각형 (JAVA)

    백준 1932. 정수 삼각형 (JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[][] arr; static int[][] dp; static int n; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; n = Integer.parseInt(br.readLine()); arr = n..

    백준 19947. 투자의 귀재 배주형 (JAVA) (DP)

    백준 19947. 투자의 귀재 배주형 (JAVA) (DP)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[] dp ; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int H = Integer.parseInt(st.nextToken()); ..

    백준 11047. 동전 0 (JAVA)

    백준 11047. 동전 0 (JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int N = Integer.parseInt(st.nextToken()); int K = Integer.pa..

    백준 15649. N과 M(1)(JAVA)

    백준 15649. N과 M(1)(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static int[] arr; static boolean[] visit; static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new Str..

    백준 9461. 파도반 수열(JAVA)

    백준 9461. 파도반 수열(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static Long[] dp = new Long[101]; public static void main(String[] arge) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int test_case = Integer.parseInt(br.readLine()); dp[1] = 1L; dp[2] = 1L; dp[3..

    백준 1003. 피보나치 함수(JAVA)

    백준 1003. 피보나치 함수(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static Integer[][] dp = new Integer[41][2]; public static void main(String[] arge) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int test_case = Integer.parseInt(br.readLine()); dp[0][0] = 1; dp[0][1] = 0; dp[1][0] = 0; dp[1][1] = 1; fo..

    백준 2231. 분해합 (JAVA)

    백준 2231. 분해합 (JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] arge) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int result = 0; for(int i = 0 ; i < N ;i++) { int num = find(i); // 분해합 구함.... if(num == N) { // 분해합이 N과 같으면 r..