[BaekJoon] 11057 오르막 수 (Java)

SeongWon Oh·2021년 11월 23일
0
post-thumbnail

🔗 문제 링크

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


📝 문제 설명


👨🏻‍💻 작성한 코드

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		
		int[][] dp = new int[N][10];
		for (int i=0; i<10; i++) {
			dp[0][i] = 1;
		}
		
		for (int i=1; i<N; i++) {
			for (int j=0; j<10; j++) {
				int sum = 0;
				for (int k=0; k<=j; k++) {
					sum += dp[i-1][k];
				}
				dp[i][j] = sum % 10007;
			}
		}
		
		int result = 0;
		for (int i=0; i<10; i++) {
			result += dp[N-1][i];
		}
		
		System.out.println(result % 10007);
		
	}

}

profile
블로그 이전했습니다. -> https://seongwon.dev/

0개의 댓글