From 8df37beb4d04909ce27ad15ee58dfab99dfd4bac Mon Sep 17 00:00:00 2001 From: Minsung_Kang Date: Sun, 18 Feb 2024 21:59:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?2024-02-18=20=EC=89=AC=EC=9A=B4=20=EA=B3=84?= =?UTF-8?q?=EB=8B=A8=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rivkms/DP/10844.cpp | 37 +++++++++++++++++++++++++++++++++++++ rivkms/README.md | 1 + 2 files changed, 38 insertions(+) create mode 100644 rivkms/DP/10844.cpp diff --git a/rivkms/DP/10844.cpp b/rivkms/DP/10844.cpp new file mode 100644 index 0000000..8a7cc29 --- /dev/null +++ b/rivkms/DP/10844.cpp @@ -0,0 +1,37 @@ +#include +#include +#include + +using namespace std; + +vector> vec(101,vector (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; +} diff --git a/rivkms/README.md b/rivkms/README.md index 2447a7b..6041bca 100644 --- a/rivkms/README.md +++ b/rivkms/README.md @@ -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/10) | --- From add8262bc35dc6778ceb05b9ef65b441fd257875 Mon Sep 17 00:00:00 2001 From: Minsung_Kang Date: Mon, 19 Feb 2024 02:28:29 +0900 Subject: [PATCH 2/2] Update README.md --- rivkms/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivkms/README.md b/rivkms/README.md index 6041bca..820c4c5 100644 --- a/rivkms/README.md +++ b/rivkms/README.md @@ -4,5 +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/10) | +| 3차시 | 2024.02.18 | DP | [하노이 탑 이동 순서](https://www.acmicpc.net/problem/10844) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/11) | ---