백준 11726번: 2xn 타일링
2021. 9. 15. 15:07ㆍAlgorithm/백준
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// 2xN 타일링
// 2xN 크기의 직사각형을 1x2, 2x1 타일로 채우는 방법의 수를 구하는 프로그램을 작성하시오.
public class Baekjoon11726 {
static int[] DP;
static int N;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(in.readLine());
DP = new int[1001]; // n 이 1000까지
DP[1] = 1;
DP[2] = 2;
dp(DP,N);
System.out.println(dp(DP,N));
}
public static int dp(int[] DP, int n) {
for (int i = 3; i <=N; i++) {
DP[i] = (DP[i-1]+DP[i-2])% 10007;
}
return DP[n];
}
}
728x90
'Algorithm > 백준' 카테고리의 다른 글
백준 17608번: 막대기 (0) | 2022.03.20 |
---|---|
백준 2810번: 컵홀더 (0) | 2022.03.19 |
백준 2133번 : 타일 채우기 (java) (0) | 2021.09.15 |
백준 8958번: OX퀴즈 (0) | 2021.08.31 |
백준 3052번: 나머지 (0) | 2021.08.31 |