강의

멘토링

커뮤니티

Inflearn Community Q&A

kihyun57415957's profile image
kihyun57415957

asked

Algorithm Coding Test to Pass in 2 Weeks (2024)

Optimization (Integer Theory) - (Difficulty ⭐️⭐️⭐️⭐️⭐️, Feel free to skip.)

2강 정수론 문제3 #1407 질문

Written on

·

116

0

let [a, b] = require("fs")
  .readFileSync(0)
  .toString()
  .trim()
  .split(" ")
  .map(Number);

function count(num) {
  let sum = num;
  for (let i = 1; i < 99; i++) {
    sum += (2 ** i - 2 ** (i - 1)) * Math.floor(num / 2 ** i);
  }

  return sum;
}

console.log(count(b) - count(a - 1));

백준에 이렇게 제출하면 틀렸다는 답이 나옵니다. 어떤 문제일까요? ㅜㅜ BigInt로도 해봤는데 안 됩니다..

python코딩-테스트알고리즘javascript

Answer

This question is waiting for answers
Be the first to answer!
kihyun57415957's profile image
kihyun57415957

asked

Ask a question