This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
long long d[101][10]; | |
long long mod = 1000000000; | |
int main() { | |
int n; | |
cin >> n; | |
for (int i=1; i<=9; i++) { | |
d[1][i] = 1; | |
} | |
for (int i=2; i<=n; i++) { | |
for (int j=0; j<=9; j++) { | |
d[i][j] = 0; | |
if (j-1 >= 0) { | |
d[i][j] += d[i-1][j-1]; | |
} | |
if (j+1 <= 9) { | |
d[i][j] += d[i-1][j+1]; | |
} | |
d[i][j] %= mod; | |
} | |
} | |
long long ans = 0; | |
for (int i=0; i<=9; i++) { | |
ans += d[n][i]; | |
} | |
ans %= mod; | |
cout << ans << '\n'; | |
return 0; | |
} |
문제 :
https://www.acmicpc.net/problem/10844
'문제풀이 > 백준' 카테고리의 다른 글
1085 - 직사각형 (0) | 2021.09.11 |
---|---|
14502 - 연구소 (0) | 2021.09.11 |
4948 - 베르트랑 공준 (0) | 2021.09.11 |
1932 - 정수 삼각형 (0) | 2021.09.11 |
1436 - 영화감독 숌 (0) | 2021.08.28 |