Skip to content

Commit

Permalink
Merge pull request #8 from AlgoLeadMe/2-dhlee777
Browse files Browse the repository at this point in the history
2-dhlee777
  • Loading branch information
dhlee777 authored Mar 19, 2024
2 parents 5f3b987 + 19d54c2 commit 892ba94
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dhlee777/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2023.10.27 | BFS | - | - |
| 1μ°¨μ‹œ | 2024.03.12 | BFS | [μˆ¨λ°”κΌ­μ§ˆ](https://www.acmicpc.net/problem/1697) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/4)|
| 2μ°¨μ‹œ | 2024.03.18 | DP | [μ‰¬μš΄κ³„λ‹¨μˆ˜](https://www.acmicpc.net/problem/10844) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-8/pull/8)|


---
23 changes: 23 additions & 0 deletions dhlee777/dp/μ‰¬μš΄κ³„λ‹¨μˆ˜.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<iostream>
using namespace std;
long long int stair_num[101][11]; //nλ²ˆμ§Έμžλ¦¬μ— mμ΄μ™”μ„λ•Œ κ°€λŠ₯ν•œ κ³„λ‹¨μ˜μˆ˜
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int num;
cin >> num; //μ²«μ§Έμžλ¦¬μˆ˜λŠ” 0은 μ œμ™Έν•˜κ³  μ–΄λ–€μˆ˜κ°€ μ˜€λ“  κ²½μš°μ˜μˆ˜λŠ” 1이닀.
for (int j = 1; j <= 9; j++)
stair_num[1][j] = 1;
for (int i = 2; i <=num; i++) { //μ–΄λ–€μžλ¦¬μˆ˜κ°€ 0일경우 κ·Έμ „μžλ¦¬μˆ˜λŠ” 1μ΄μ–΄μ•Όν•œλ‹€.
for (int j =0; j <10; j++) {
if (!j) stair_num[i][j] = stair_num[i - 1][1];
stair_num[i][j] = (stair_num[i - 1][j - 1] + stair_num[i - 1][j + 1])%1000000000;
}
}
long long int sum = 0;
for (int j = 0; j < 10; j++) { //제일 λ§ˆμ§€λ§‰μžλ¦¬μ— 0~9 κ°€ μ˜€λŠ” κ²½μš°μ˜μˆ˜λ“€μ„ 각각 λ‹€ 더해쀀닀.
sum += stair_num[num][j];
}
cout << sum%1000000000;
return 0;
}

0 comments on commit 892ba94

Please sign in to comment.