From 7ade3ed3bb1a64c90480335b59ce61895babd21e Mon Sep 17 00:00:00 2001 From: SeongWooHong Date: Sat, 2 Mar 2024 00:11:29 +0900 Subject: [PATCH] 2024-03-01 --- Redish03/DP/9461.cpp | 39 +++++++++++++++++++++++++++++++++++++++ Redish03/README.md | 5 +++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Redish03/DP/9461.cpp diff --git a/Redish03/DP/9461.cpp b/Redish03/DP/9461.cpp new file mode 100644 index 0000000..2812c87 --- /dev/null +++ b/Redish03/DP/9461.cpp @@ -0,0 +1,39 @@ +#include + +using namespace std; + +long long dp[101] = { + 0, +}; + +long long rec(int N) +{ + if (dp[N] != 0) + { + return dp[N]; + } + if (N == 1 || N == 2 || N == 3) + { + dp[N] = 1; + return 1; + } + + dp[N] = rec(N - 2) + rec(N - 3); + return dp[N]; +} + +int main() +{ + ios_base::sync_with_stdio(0); + cin.tie(0); + cout.tie(0); + + int T, N; + cin >> T; + + for (int i = 0; i < T; i++) + { + cin >> N; + cout << rec(N) << '\n'; + } +} \ No newline at end of file diff --git a/Redish03/README.md b/Redish03/README.md index 88c5a6a..f4ab26d 100644 --- a/Redish03/README.md +++ b/Redish03/README.md @@ -16,7 +16,8 @@ | 12차시 | 2024.02.03 | DP | [구간 합 구하기 5](https://www.acmicpc.net/problem/11660) | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/47) | | 13차시 | 2024.02.06 | Back tracking | [N과 M(9)](https://www.acmicpc.net/problem/15663) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/52) | | 14차시 | 2024.02.12 | KnapSack(DP) | [평범한 배낭](https://www.acmicpc.net/problem/12865) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/55) | -| 15차시 | 2024.02.15 | DFS | [트리의 지름](https://www.acmicpc.net/problem/1167) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/55) | -| 16차시 | 2024.02.27 | DP | [쉬운 계단 수](https://www.acmicpc.net/problem/10844) | [#15](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/68) | +| 15차시 | 2024.02.15 | DFS | [트리의 지름](https://www.acmicpc.net/problem/1167) | [#15](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/55) | +| 16차시 | 2024.02.27 | DP | [쉬운 계단 수](https://www.acmicpc.net/problem/10844) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/68) | +| 17차시 | 2024.03.01 | DP | [파도반 수열](https://www.acmicpc.net/problem/9461) | [#17](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/68) | ---