Skip to content

Commit

Permalink
2024-08-10
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Aug 10, 2024
1 parent 0d211e0 commit 6639482
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@
| 65์ฐจ์‹œ | 2024.07.19 | ์ตœ์†Œ ๊ณตํ†ต ์กฐ์ƒ | <a href="https://www.acmicpc.net/problem/3584">๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/220
| 66์ฐจ์‹œ | 2024.07.22 | DP | <a href="https://www.acmicpc.net/problem/2169">๋กœ๋ด‡ ์กฐ์ข…ํ•˜๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/222
| 67์ฐจ์‹œ | 2024.07.26 | DP | <a href="https://www.acmicpc.net/problem/3687">์„ฑ๋ƒฅ๊ฐœ๋น„</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/223
| 69์ฐจ์‹œ | 2024.08.10 | ๋ˆ„์ ํ•ฉ, ์ˆ˜ํ•™ | <a href="https://www.acmicpc.net/problem/9527">1์˜ ๊ฐœ์ˆ˜ ์„ธ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/228
---
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 6639482

Please sign in to comment.