[BOJ][C#] 2133 타일 채우기

LimJaeJun·2023년 8월 5일
0

PS/BOJ

목록 보기
8/108

📕 문제

📌 링크
문제 사진

📘 코드

namespace BOJ
{
    class No_2133
    {
        static void Main()
        {
            using StreamReader input = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
            using StreamWriter output = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));

            int n = int.Parse(input.ReadLine());

            int[] dp = new int[31];

            dp[0] = 1;
            dp[2] = 3;

            if (n > 2)
            {
                for(int i = 4 ; i <= n ; i++)
                {
                    dp[i] = dp[i - 2] * 3;

                    for(int j = i - 4 ; j >= 0 ; j -= 2)
                        dp[i] += dp[j] * 2;
                }
            }

            output.WriteLine(dp[n]);
        }
    }
}

📙 오답노트

점화식을 애초에 잘 못 세우고 풀이를 진행하였다..
점화식은 링크를 참고하였다.

📒 알고리즘 분류

  • 다이나믹 프로그래밍
profile
Dreams Come True

0개의 댓글

관련 채용 정보