녕의 학습 기록

백준_11726 2xn 타일링 (DP) 본문

Algorithm/Algorithm 문제

백준_11726 2xn 타일링 (DP)

kjyyjk 2024. 4. 15. 22:04

 

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<n+1; i++) {
            d[i] = ((d[i-1] % 10007) + (d[i-2] % 10007)) % 10007;
        }

        System.out.println(new StringBuilder().append(d[n]));
    }

}
 

11726번: 2×n 타일링

2×n 크기의 직사각형을 1×2, 2×1 타일로 채우는 방법의 수를 구하는 프로그램을 작성하시오. 아래 그림은 2×5 크기의 직사각형을 채운 한 가지 방법의 예이다.

www.acmicpc.net

 

'Algorithm > Algorithm 문제' 카테고리의 다른 글

백준_13398 연속합 2 (DP)  (0) 2024.04.18
백준_10844 쉬운 계단 수 (DP)  (0) 2024.04.16
백준_2193 이친수 (DP)  (0) 2024.04.14
백준_14501 퇴사 (DP)  (0) 2024.04.13
백준_1463 1로 만들기 (DP)  (0) 2024.04.11