Skip to content

Commit

Permalink
2024-02-19
Browse files Browse the repository at this point in the history
  • Loading branch information
miniron-v committed Feb 18, 2024
1 parent 7585ca3 commit 7ae5938
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
7 changes: 5 additions & 2 deletions miniron-v/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
---
36 changes: 36 additions & 0 deletions miniron-v/μˆ˜ν•™/1081-ν•©.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>

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);
}

0 comments on commit 7ae5938

Please sign in to comment.