[BOJ][C#] 11057 오르막 수

LimJaeJun·2023년 8월 1일
0

PS/BOJ

목록 보기
3/108

📕 문제

📌 링크
문제 사진

📘 코드

namespace BOJ
{
    class No_11057
    {
        const int MOD = 10_007;

        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());

            // 오르막 수 : 수의 자리가 오름차순 or 같은 수

            int[,] dp = new int[n + 1, 10];

            for(int i = 0 ; i < 10 ; i++)
                dp[1, i] = 1;

            for(int i = 1 ; i <= n ; i++)
                for(int j = 0 ; j < 10 ; j++)
                    for(int k=0 ;k<=j ;k++)
                        dp[i, j] = (dp[i, j] + dp[i - 1, k]) % MOD;
                    
            long answer = 0;
            for(int i = 0 ; i < 10 ; i++)
                answer += dp[n, i];

            output.WriteLine(answer % MOD);
        }
    }
}

📙 오답노트

📒 알고리즘 분류

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

0개의 댓글

관련 채용 정보