회고

[개발일지] - 640

Happy Programmer 2025. 4. 4. 00:22

(1).백준 3733번 Shares는 주식을 나누는 문제로

x명과 판사가 존재할 때 y개의 주식을 몇개씩 가질 수 있는지 출력하기 위해서

총 주식의 개수(y)에서 판사 + x명을 나눈 값을 Math.floor로 나눔처리해서 출력하는 방식으로 해결했다.

const input = `1 100
2 7
10 9
10 10`.split('\n').map(el => el.split(' ').map(Number))


for(let i = 0 ; i < input.length ; i++){
    const [x, y] = input[i]

    console.log(Math.floor(y / (x + 1)))
}