Algorithm/Baekjoon

[Algorithm/Baekjoon] 오르막 수 - 11057 (S1/JAVA)

dpdms2148 2024. 9. 30. 20:44
728x90

📑문제링크

https://www.acmicpc.net/problem/11057

 

💻코드

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[][] dp = new int[1002][10];

        for (int i = 0; i < 10; i++) {
            dp[1][i] = 1;
        }
        for (int i = 2; i <= N; i++) {
            for (int j = 0; j < 10; j++) {
                if (j == 0) {
                    dp[i][j] = 1;
                    continue;
                }

                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= 10007;
            }
        }

        int answer = 0;
        for (int i = 0; i < 10; i++) {
            answer += (dp[N][i] % 10007);
        }
        System.out.println(answer % 10007);

    }
}
728x90