언젠가는 펼쳐 볼 아카이브
[BOJ] 2884 - 알람시계 본문
사용언어 : javascript - node.js
# 제출코드
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
let input = fs.readFileSync(filePath).toString().split('\n');
input = input[0];
input = input.split(' ').map((item) => +item);
solution(input[0], input[1]);
function solution(h, m) {
let hour = h;
let min = m - 45;
if (min < 0) {
if (hour === 0) {
hour = 23;
} else {
hour--;
}
min = 60 - Math.abs(min);
}
console.log(`${hour} ${min}`);
}
'IT > Baekjoon Oline Judge' 카테고리의 다른 글
[BOJ] 2480번 - 주사위 세개 (0) | 2023.08.15 |
---|---|
[BOJ] 2525 - 오븐 시계 (0) | 2023.08.15 |
[BOJ] 14681번 - 사분면 고르기 (0) | 2023.08.15 |
[BOJ] 2753번 - 윤년 (0) | 2023.08.15 |
[BOJ] 1330번 - 두 수 비교하기 (0) | 2023.08.15 |