https://www.acmicpc.net/problem/10844
#include<iostream>
#include <algorithm>
using namespace std;
int n;
const int DIV = 1000000000;
int solution(){
int num[10] ={0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
int temp[10];
for(int i=1;i<n;i++){
temp[0] = num[1];
temp[9] = num[8];
for(int j=1;j<9;j++)
temp[j] = (num[j-1]+num[j+1])%DIV;
for(int i=0;i<10;i++)
num[i] = temp[i];
}
int answer =0;
for(int i=0;i<10;i++)
answer = (answer + num[i])%DIV;
return answer;
}
#include <stdio.h>
int main()
{
int n, dp[101][10] = { 0 };
long long result = 0;
scanf("%d", &n);
for (int i = 0; i <= 9; i++)
dp[1][i] = 1;
for (int i = 2; i <= n; i++)
{
for (int j = 0; j <= 9; j++)
{
long long sum = 0;
if (j - 1 >= 0)
sum += dp[i - 1][j - 1];
if (j + 1 <= 9)
sum += dp[i - 1][j + 1];
dp[i][j] = sum % 1000000000;
}
}
for (int i = 1; i <= 9; i++)
{
result += dp[n][i];
result %= 1000000000;
}
printf("%lld", result);
return 0;
}