delpho
[실버3, DP] 백준 11726 - 2xn 타일링 (자바) 본문
Think
1. 점화식을 잘못 찾아서 틀렸다.
2. https://yinq.tistory.com/68 를 참고하여 풀었다.
3. 예제를 활용하여 점화식을 검토하는 방법이 있다.
4. 문제를 여러 개 풀면서 여러 점화식을 접해보자.
제출 코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static int n;
static Integer dp[];
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
public static void main(String[] args) throws IOException {
init();
progress();
}
private static void progress() {
dp = new Integer[n + 2];
dp[0] = 0;
dp[1] = 1;
dp[2] = 2;
System.out.println(recursion(n));
}
private static int recursion(int n) {
if(dp[n] == null){
dp[n] = (recursion(n-1) + recursion(n-2)) % 10007;
}
return dp[n];
}
private static void init() throws IOException {
n = Integer.parseInt(br.readLine());
}
}
'알고리즘 > DP' 카테고리의 다른 글
[실버3, DP] 백준 2579 - 계단 오르기 (자바) (0) | 2024.03.04 |
---|---|
[실버2, DP] 백준 11053 - 가장 긴 증가하는 부분 수열 (자바) (0) | 2024.03.04 |
[실버3, DP] 백준 1003 - 피보나치 함수 (자바) (0) | 2024.02.29 |
[실버3, DP] 백준 9095 - 1, 2, 3 더하기 (자바) (0) | 2024.02.29 |
[실버3, DP] 백준 1463 - 1로 만들기 (자바) (0) | 2024.02.29 |