complete 2252.py 2623.py 9527.py 31403.py 32822.py

This commit is contained in:
2025-01-13 17:37:34 +09:00
parent 1b90d0f5bf
commit 7841cb80bf
5 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
def S(n: int):
s = n & 1
for i in range(60 - 1, 0, -1):
if n & (1 << i):
s += S.points[i - 1] + (n - (1 << i) + 1)
n -= 1 << i
return s
S.points = [0] * 60
S.points[0] = 1
for i in range(1, 60):
S.points[i] = 2 * S.points[i - 1] + (1 << i)
if __name__ == "__main__":
A, B = map(int, input().split())
print(S(B) - S(A - 1))