(1).백준 27590번 Sun and Moon은 일식의 날짜를 구해야 하는 문제로

각각 같은 값이 될 때까지 시작점에서 해와 달의 주기를 더 적은 값에 더해주는 방식으로 해결했다.

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

const x = input[0][1]
const y = input[1][1]
let a = -input[0][0]
let b = -input[1][0]

while (a != b) {
    if(a < b){
        a += x
    }
    else{
        b += y
    }
}

console.log(a)

'회고' 카테고리의 다른 글

[개발일지] - 624  (0) 2025.03.18
[개발일지] - 623  (0) 2025.03.17
[개발일지] - 621(주말)  (0) 2025.03.15
[개발일지] - 620  (0) 2025.03.14
[개발일지] - 619  (0) 2025.03.13

+ Recent posts