diff --git a/yuyu0830/DP/1562.cpp b/yuyu0830/DP/1562.cpp new file mode 100644 index 0000000..cedb9f7 --- /dev/null +++ b/yuyu0830/DP/1562.cpp @@ -0,0 +1,40 @@ +#include + +#define MOD 1000000000 + +using namespace std; + +int arr[101][10][1024] = {0, }; + +int main() { + int n; cin >> n; + + for (int i = 1; i < 10; i++) { + arr[1][i][1 << i] = 1; + } + + for (int i = 2; i <= n; i++) { + for (int j = 0; j < 10; j++) { + for (int k = 0; k < 1024; k++) { + if (j) { + arr[i][j][k | (1 << j)] += arr[i - 1][j - 1][k]; + arr[i][j][k | (1 << j)] %= MOD; + } + + if (j != 9) { + arr[i][j][k | (1 << j)] += arr[i - 1][j + 1][k]; + arr[i][j][k | (1 << j)] %= MOD; + } + } + } + } + + int ans = 0; + + for (int i = 0; i < 10; i++) { + ans += arr[n][i][1023]; + ans %= MOD; + } + + printf("%d\n", ans); +} \ No newline at end of file diff --git a/yuyu0830/README.md b/yuyu0830/README.md index 4ec30d9..50e1cc9 100644 --- a/yuyu0830/README.md +++ b/yuyu0830/README.md @@ -22,4 +22,5 @@ | 18차시 | 2024.07.06 | 구현 | [2048 (Easy)](https://www.acmicpc.net/problem/12100) | - | | 19차시 | 2024.07.12 | 재귀 | [우수마을](https://www.acmicpc.net/problem/1949) | - | | 20차시 | 2024.07.22 | LIS | [가장 긴 증가하는 부분 수열 5](https://www.acmicpc.net/problem/14003) | - | +| 22차시 | 2024.08.05 | DP | [계단 수](https://www.acmicpc.net/problem/1562) | - | --- \ No newline at end of file