From 54c883d94d90b012a3623c7d013a96f98fa0a6e7 Mon Sep 17 00:00:00 2001 From: miniron_v <61517039+miniron-v@users.noreply.github.com> Date: Thu, 22 Feb 2024 03:39:04 +0900 Subject: [PATCH] 2024-02-21 --- ...\354\210\230\354\235\230 \355\225\251.cpp" | 24 +++++++++++++++++++ miniron-v/README.md | 1 + 2 files changed, 25 insertions(+) create mode 100644 "miniron-v/DP/1699-\354\240\234\352\263\261\354\210\230\354\235\230 \355\225\251.cpp" diff --git "a/miniron-v/DP/1699-\354\240\234\352\263\261\354\210\230\354\235\230 \355\225\251.cpp" "b/miniron-v/DP/1699-\354\240\234\352\263\261\354\210\230\354\235\230 \355\225\251.cpp" new file mode 100644 index 0000000..1461acc --- /dev/null +++ "b/miniron-v/DP/1699-\354\240\234\352\263\261\354\210\230\354\235\230 \355\225\251.cpp" @@ -0,0 +1,24 @@ +#include +#include + +int main() { + int n; + std::cin >> n; + + std::vector dp(n + 1, 0); + dp[1] = 1; + + for (int i = 2; i <= n; ++i) { + int min_index = i - 1; + + for (int j = 2; j * j <= i; ++j) { + if (dp[i - (j * j)] < dp[min_index]) { + min_index = i - (j * j); + } + } + + dp[i] = dp[min_index] + 1; + } + + std::cout << dp[n]; +} \ No newline at end of file diff --git a/miniron-v/README.md b/miniron-v/README.md index f8ea8e1..d2bb009 100644 --- a/miniron-v/README.md +++ b/miniron-v/README.md @@ -19,4 +19,5 @@ | 14차시 | 2024.02.11 | 그래프, DP | [ACM Craft](https://www.acmicpc.net/problem/1005) | [#53](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/53) | | 15차시 | 2024.02.15 | DP, 큰 수 연산 | [타일링](https://www.acmicpc.net/problem/1793) | [#56](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/56) | | 16차시 | 2024.02.18 | 수학 | [합](https://www.acmicpc.net/problem/1081) | [#61](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/61) | +| 17차시 | 2024.02.21 | DP | [제곱수의 합](https://www.acmicpc.net/problem/1699) | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/64) | ---