초콜릿 향연 설명 - 솔루션 | Javascript

2316 단어
function chocolateFeast(n, c, m) {
  let candy = Math.floor(n / c);
  let wrapper = candy;
  let result = candy;
  while(wrapper >= m) {
    const exchanged = Math.floor(wrapper / m);
    wrapper = wrapper - (exchanged * m) + exchanged;
    result+= exchanged;
  }
  return result;
}

chocolateFeast(10, 2, 5);
Problem

좋은 웹페이지 즐겨찾기