diff --git a/code_study/Baekjoon/python/9527.py b/code_study/Baekjoon/python/9527.py new file mode 100644 index 0000000..855fa30 --- /dev/null +++ b/code_study/Baekjoon/python/9527.py @@ -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)) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/1598.ts b/code_study/Baekjoon/ts/1598.ts new file mode 100644 index 0000000..b943444 --- /dev/null +++ b/code_study/Baekjoon/ts/1598.ts @@ -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) +); \ No newline at end of file