본문 바로가기
알고리즘 & 자료구조/백준

백준 11057

by 신재권 2021. 9. 8.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main11057 {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine()); //수의 길이 N
		long[][] D = new long[N+1][10];
		final int MOD = 10_007;
		
		for(int i=0; i<10; i++){
			D[1][i] = 1; //수의 길이가 1이면 모두 오르막수이다.
		}
		//점화식
		//D[i][j] = 길이가 i이고 마지막 숫자가 j인 오르막 수의 개수
		//D[i][j] += D[i-1][k](0<= k <= j)
		
		for(int i=2; i<=N; i++){ 
			for(int j=0; j<10; j++){ //j의 범위 마지막 숫자는 0부터 9까지 가능
				for(int k=0; k<=j; k++){ //k의 범위 (0<= k <= j)
					D[i][j] += D[i-1][k]; //모든 경우의 수를 더해준다.
					D[i][j] %= MOD;
				}
			}
		}
		long ans = 0;
		for(int i=0; i<10; i++){
			ans += D[N][i];
		}
		ans %= MOD;
		System.out.println(ans);
		
		
		
	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 2156  (0) 2021.09.08
백준 9465  (0) 2021.09.08
백준 1309  (0) 2021.09.07
백준 1149  (0) 2021.09.06
백준 15988  (0) 2021.09.05