백준_10844 쉬운 계단 수 (DP)Algorithm/Algorithm 문제2024. 4. 16. 22:42
Table of Contents
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BJ_10844_쉬운계단수 {
static long M = 1000000000;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
long[][] d = new long[n+1][10];
int i, j;
for (i=1; i<10; i++) {
d[1][i] = 1;
}
for (i=2; i<n+1; i++) {
d[i][0] = d[i-1][1];
d[i][9] = d[i-1][8];
for (j=1; j<9; j++) {
d[i][j] = (d[i-1][j-1] + d[i-1][j+1]) % M;
}
}
long result = 0;
for (i=0; i<10; i++) {
result = (result + d[n][i]) % M;
}
System.out.println(new StringBuilder().append(result));
}
}
'Algorithm > Algorithm 문제' 카테고리의 다른 글
백준_9252 LCS 2 (DP) (1) | 2024.04.21 |
---|---|
백준_13398 연속합 2 (DP) (0) | 2024.04.18 |
백준_11726 2xn 타일링 (DP) (0) | 2024.04.15 |
백준_2193 이친수 (DP) (0) | 2024.04.14 |
백준_14501 퇴사 (DP) (0) | 2024.04.13 |
@kjyyjk :: 녕의 학습 기록
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!