-
Notifications
You must be signed in to change notification settings - Fork 2
/
김지원.java
35 lines (28 loc) · 942 Bytes
/
김지원.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static int N;
static int[] dp;
public static void main(String[] args) throws Exception {
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
long[][] dp = new long[101][11];
// dp[N][L] = dp[N - 1][L - 1] + dp[N - 1][L + 1]
// 길이 N, 마지막 숫자가 L일 경우
for (int i = 1; i <= 9; i++) {
dp[1][i] = 1;
}
for (int i = 2; i <= N; i++) {
dp[i][0] = dp[i - 1][1];
for (int j = 1; j <= 9; j++) {
dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1]) % 1000000000;
}
}
long sum = 0;
for (int i = 0; i < 10; i++) {
sum += dp[N][i];
}
System.out.println(sum % 1000000000);
}
}