baekjoon 20260208
This commit is contained in:
parent
2b24a0a06c
commit
9eb6786614
17
code_study/Baekjoon/python/9527.py
Normal file
17
code_study/Baekjoon/python/9527.py
Normal file
@ -0,0 +1,17 @@
|
||||
dp = [0] * 55
|
||||
for n in range(1,55) :
|
||||
dp[n] = 2*dp[n-1] + (1 << (n-1))
|
||||
|
||||
def countOne(N) :
|
||||
ans = 0
|
||||
for n in range(54,0,-1) :
|
||||
MSB = N & (1 << (n-1))
|
||||
|
||||
if MSB :
|
||||
N -= MSB
|
||||
ans += dp[n-1] + (N + 1)
|
||||
|
||||
return ans
|
||||
|
||||
A, B = map(int, input().split())
|
||||
print(countOne(B) - countOne(A-1))
|
||||
6
code_study/Baekjoon/ts/1598.ts
Normal file
6
code_study/Baekjoon/ts/1598.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export {};
|
||||
const [A, B]: number[] = require("fs").readFileSync(0).toString().trim().split(" ").map(Number);
|
||||
console.log(
|
||||
Math.abs(Math.floor((A-1)/4) - Math.floor((B-1)/4)) +
|
||||
Math.abs((A-1)%4 - (B-1)%4)
|
||||
);
|
||||
Loading…
x
Reference in New Issue
Block a user