Skip to content

Commit

Permalink
24-08-05 계단 수
Browse files Browse the repository at this point in the history
  • Loading branch information
makehard23 committed Aug 5, 2024
1 parent bb05371 commit bd51d66
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions yuyu0830/DP/1562.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>

#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);
}
1 change: 1 addition & 0 deletions yuyu0830/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | - |
---

0 comments on commit bd51d66

Please sign in to comment.