From 7ae593849559460049978e6c604fa9d7f61e588d Mon Sep 17 00:00:00 2001 From: miniron_v <61517039+miniron-v@users.noreply.github.com> Date: Mon, 19 Feb 2024 02:15:39 +0900 Subject: [PATCH] 2024-02-19 --- miniron-v/README.md | 7 ++-- .../1081-\355\225\251.cpp" | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 "miniron-v/\354\210\230\355\225\231/1081-\355\225\251.cpp" diff --git a/miniron-v/README.md b/miniron-v/README.md index eac5d20..f8ea8e1 100644 --- a/miniron-v/README.md +++ b/miniron-v/README.md @@ -14,6 +14,9 @@ | 10차시 | 2024.01.28 | 그래프 | [토마토](https://www.acmicpc.net/problem/7569) | [#38](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/38) | | 번외 - 10 | 2024.01.30 | 그래프 | [하이퍼 토마토](https://www.acmicpc.net/problem/17114) | [#42](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/42) | | 11차시 | 2024.01.31 | 브루트포스 | [감소하는 수](https://www.acmicpc.net/problem/1038) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/43) | -| 12차시 | 2024.01.31 | DP | [점프 점프](https://www.acmicpc.net/problem/11060) | [#48](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/48) | -| 13차시 | 2024.01.31 | DP | [퇴사 2](https://www.acmicpc.net/problem/15486) | [#50](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/50) | +| 12차시 | 2024.02.03 | DP | [점프 점프](https://www.acmicpc.net/problem/11060) | [#48](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/48) | +| 13차시 | 2024.02.06 | DP | [퇴사 2](https://www.acmicpc.net/problem/15486) | [#50](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/50) | +| 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) | --- diff --git "a/miniron-v/\354\210\230\355\225\231/1081-\355\225\251.cpp" "b/miniron-v/\354\210\230\355\225\231/1081-\355\225\251.cpp" new file mode 100644 index 0000000..76daf6a --- /dev/null +++ "b/miniron-v/\354\210\230\355\225\231/1081-\355\225\251.cpp" @@ -0,0 +1,36 @@ +#include + +long long gaussSum(long long k) { + if (k % 2 == 0) { + return (k / 2) * (k + 1); + } + + return ((k + 1) / 2) * k; +} + +long long getSumOfPlace(long long n) { + if (n < 1) { + return 0; + } + + long long answer = gaussSum(n); + + long long d = 10; + while ((n / d) > 0) { + long long q = n / d; + long long r = n % d; + + answer -= 9 * (gaussSum(q - 1) * d + q * (r + 1)); + + d *= 10; + } + + return answer; +} + +int main() { + long long l, u; + std::cin >> l >> u; + + std::cout << getSumOfPlace(u) - getSumOfPlace(l - 1); +} \ No newline at end of file