Skip to content

Commit

Permalink
Merge pull request #11 from AlgoLeadMe/3-rivkms
Browse files Browse the repository at this point in the history
3-rivkms
  • Loading branch information
rivkms authored Feb 21, 2024
2 parents a3f2ab5 + add8262 commit eb633b5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions rivkms/DP/10844.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> vec(101,vector<int> (10,0));

int func(const int & n, const int & a){
if(vec[n][a]){
return vec[n][a];
}
else if(a==0){
return vec[n][a] = func(n-1, 1)%1000000000;
}
else if(a==9){
return vec[n][a] = func(n-1, 8)%1000000000;
}
return vec[n][a] = ((func(n-1, a-1)) + (func(n-1, a+1)))%1000000000;
}

int main(){
int n, sum = 0;
cin >> n;


for(int i = 0 ;i<=9; i++){
vec[1][i] = 1;
}

for(int i = 1; i<=9; i++){
sum+=func(n ,i);
sum%=1000000000;
}
cout << sum;
return 0;
}
1 change: 1 addition & 0 deletions rivkms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.02.12 | DP | [ν‰λ²”ν•œ λ°°λ‚­](https://www.acmicpc.net/problem/12865) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/5) |
| 2μ°¨μ‹œ | 2024.02.15 | Recursion | [ν•˜λ…Έμ΄ 탑 이동 μˆœμ„œ](https://www.acmicpc.net/problem/11729) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/8) |
| 3μ°¨μ‹œ | 2024.02.18 | DP | [ν•˜λ…Έμ΄ 탑 이동 μˆœμ„œ](https://www.acmicpc.net/problem/10844) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/11) |
---

0 comments on commit eb633b5

Please sign in to comment.