백준_9252 LCS 2 (DP)
Algorithm/Algorithm 문제2024. 4. 21. 00:36백준_9252 LCS 2 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_9252_LCS2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s1 = br.readLine(); String s2 = br.readLine(); int[][] d = new int[s1.length() + 1][s2.length() + 1]; int i, j; for (i = 1; i < s1.lengt..

백준_13398 연속합 2 (DP)
Algorithm/Algorithm 문제2024. 4. 18. 01:50백준_13398 연속합 2 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_13398_연속합2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] a = new int[n]; int[] l = new int[n]; int[] r = new int[n]; i..

백준_10844 쉬운 계단 수 (DP)
Algorithm/Algorithm 문제2024. 4. 16. 22:42백준_10844 쉬운 계단 수 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_10844_쉬운계단수 { static long M = 1000000000; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); long[][] d = new long[n+1][10]; int i, j; for (i=1; i

백준_11726 2xn 타일링 (DP)
Algorithm/Algorithm 문제2024. 4. 15. 22:04백준_11726 2xn 타일링 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_11726_2xN타일링 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] d = new int[n+2]; d[1] = 1; d[2] = 2; for (int i=3; i

백준_2193 이친수 (DP)
Algorithm/Algorithm 문제2024. 4. 14. 17:13백준_2193 이친수 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_2193_이친수 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); long[][] d = new long[n+1][2]; //d[i][0] : i번째의 0의 개수, d[i][1] : i번째의 1의 개수 d[1][0] = 0; d[1][1] = 1; f..

백준_14501 퇴사 (DP)
Algorithm/Algorithm 문제2024. 4. 13. 21:11백준_14501 퇴사 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_14501_퇴사 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] t = new int[n + 1]; int[] p = new int[n + 1]; int[] result = ne..

백준_1463 1로 만들기 (DP)
Algorithm/Algorithm 문제2024. 4. 11. 11:41백준_1463 1로 만들기 (DP)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_1463_1로만들기 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] d = new int[n+1]; d[1] = 0; for (int i=2; i

백준_1947 선물 전달 (조합 순열)
Algorithm/Algorithm 문제2024. 4. 8. 20:14백준_1947 선물 전달 (조합 순열)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_1947_선물전달 { static long t = 1000000000; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); long[] d = new long[n+2]; //n=1 또는 2일 경우 아래 두줄에서 인덱스 에러. 따라서 n+2를 해줌 d[1] ..

백준_1256 사전 (조합 순열)
Algorithm/Algorithm 문제2024. 4. 8. 02:14백준_1256 사전 (조합 순열)

거의 4시간 들여다본 문제.. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_1256_사전 { public static void main(String[] args) throws IOException { StringBuilder result = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLi..

백준_1722 순열의 순서 (조합 순열)
Algorithm/Algorithm 문제2024. 4. 6. 20:43백준_1722 순열의 순서 (조합 순열)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_1722_순열의순서 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); boolean[] visited = new boolean[21]; //방문 배열 초기화 long[] f = new lon..

image