From 6639482ffe7178e2792e9bb1c653d8fb030e8fa5 Mon Sep 17 00:00:00 2001 From: tgyuuAn Date: Sun, 11 Aug 2024 01:42:28 +0900 Subject: [PATCH] 2024-08-10 --- tgyuuAn/README.md | 1 + ...4\354\210\230 \354\204\270\352\270\260.py" | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 "tgyuuAn/\353\210\204\354\240\201\355\225\251/1\354\235\230 \352\260\234\354\210\230 \354\204\270\352\270\260.py" diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 7789f03..2735ab8 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -74,4 +74,5 @@ | 65차시 | 2024.07.19 | 최소 공통 조상 | 가장 가까운 공통 조상 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/220 | 66차시 | 2024.07.22 | DP | 로봇 조종하기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/222 | 67차시 | 2024.07.26 | DP | 성냥개비 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/223 +| 69차시 | 2024.08.10 | 누적합, 수학 | 1의 개수 세기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/228 --- diff --git "a/tgyuuAn/\353\210\204\354\240\201\355\225\251/1\354\235\230 \352\260\234\354\210\230 \354\204\270\352\270\260.py" "b/tgyuuAn/\353\210\204\354\240\201\355\225\251/1\354\235\230 \352\260\234\354\210\230 \354\204\270\352\270\260.py" new file mode 100644 index 0000000..d9f7ee6 --- /dev/null +++ "b/tgyuuAn/\353\210\204\354\240\201\355\225\251/1\354\235\230 \352\260\234\354\210\230 \354\204\270\352\270\260.py" @@ -0,0 +1,22 @@ +import sys + +def input(): return sys.stdin.readline().rstrip() + +A, B = map(int, input().split()) + +bits = [0 for _ in range(len(bin(B)[2:]))] + +for step in range(len(bits)): + one_count_per_bundle = (2**step) + total_count_bundle = 2 * (one_count_per_bundle) + + B_d, B_m = divmod(B,total_count_bundle) + B_count = one_count_per_bundle * B_d + if(B_m >= one_count_per_bundle): B_count += min(one_count_per_bundle,(B_m - one_count_per_bundle + 1)) + + A_d, A_m = divmod(A-1,total_count_bundle) + A_count = one_count_per_bundle * A_d + if(A_m >= one_count_per_bundle): A_count += min(one_count_per_bundle, (A_m - one_count_per_bundle + 1)) + bits[step] += (B_count - A_count) + +print(sum(bits)) \ No newline at end of file