알고리즘
알고리즘문제
Okguri
2022. 7. 12. 15:52
백준 2525 번 오븐시계
const ovenTime = (hh, mm, time) => {
//time을 60으로 나눈 몫quotient과 나머지remainder를 구하기
//mm에다가 remainder 더하기.
//1) mm+remainder > 60일 때, remainder = mm+remainder -60 하고, quotient에 +1
//2) mm+remainder < 60일 때는 그냥 두기
//hh+quotient하기
// hh >=24면, hh = 0
//input 값 유효성검사
if(time<0 && time>=1000){
return 0;
}
if(!(0<=hh && 24>hh)){
return 0 ;
}
if(!(0<=mm && 59>mm)){
return ;
}
let HH = hh+ Math.floor(time/60);
let MM = mm + time%60;
console.log(HH , MM)
if(MM>=60){
MM = MM-60;
HH = HH+1;
}
return HH >= 24 ? `0 ${MM}` : `${HH} ${MM}`
}
ovenTime(70, 48, 25);