
const fs = require('fs');
const path = process.platform === 'linux' ? '/dev/stdin' : 'Wiki\\input.txt';
const [h, m] = fs.readFileSync(path).toString().trim().split(' ').map(Number);
if (h * 60 + m >= 45) {
const newH = Math.floor((h * 60 + m - 45) / 60);
const newM = (h * 60 + m - 45) % 60;
console.log(newH, newM);
} else {
const newH = Math.floor(((h + 24) * 60 + m - 45) / 60);
const newM = ((h + 24) * 60 + m - 45) % 60;
console.log(newH, newM);
}
⏰ 소요한 시간 : -
이런 시간 문제는 시를 분으로 변경하여 계산한다음에 다시 분으로 바꿔주는 것이 편리하다.
그래서 h에 60을 곱해 시를 분으로 변경하고 m과 더해준 뒤 그 값이 45보다 크다면 그 값을 시와 분으로 다시 나누어 주면 된다.
0시 30분같은 경우에는 위 연산을 했을때 값이 45보다 크지 않다. 그 경우에는 그냥 하루가 더 있다고 생각하고 증 24시간을 더해서 풀이해주면 된다.