#include <stdio.h>
const int mod=10007;

int bottom_up(int n) {
    int dp[1001][10]={0};
    //기저
    for(int i=0; i<10; i++) {
        dp[1][i]=1;
    }
    //자리수
    for(int i=2; i<=n; i++) {
        //마지막 숫자
        for(int j=0; j<=9; j++) {
            int tmp=j;
            //마지막 숫자보다 큰수를 전 자릿수에서 더함
            while(tmp<10) {
                dp[i][j]=(dp[i][j]+dp[i-1][tmp])%mod;
                tmp++;
            }
        }
    }
    int sum=0;
   for(int i=0; i<10; i++) {
       sum=(sum+dp[n][i])%mod;
   }
    return sum;
}



int main() {
    int n;
    scanf("%d",&n);
    printf("%d",bottom_up(n));
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: