๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

ํ”„์—” ๊ณต๋ถ€/๐Ÿซง ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต๋ถ€

[๋ฐฑ์ค€/Node.js] 2884๋ฒˆ ํ’€์ด || JavaScript

728x90
let input = require('fs').readFileSync('/dev/stdin').toString().split(" ");
input = input.map(Number);

const hour = input[0] == 0 ? 24 : input[0];    
const minutes = input[1];

const backTo45Minutes = hour * 60 + minutes - 45;

const earlyHour = Math.floor(backTo45Minutes / 60);
const earlyMinites = backTo45Minutes - earlyHour * 60;
console.log(earlyHour == 24 ? 0 : earlyHour, earlyMinites);

๐ŸŒฑ ์‹œ๊ฐ„์ด 0์‹œ ์ผ ๊ฒฝ์šฐ๋ฅผ ์ž˜ ๊ณ ๋ คํ•ด์„œ 24์‹œ๋กœ ๊ณ„์‚ฐํ•˜๊ณ ,

๊ณ„์‚ฐ ๊ฒฐ๊ณผ 24์‹œ๊ฐ€ ๋‚˜์˜ฌ ๊ฒฝ์šฐ ์ถœ๋ ฅ์‹œ 0์œผ๋กœ ์ถœ๋ ฅ๋˜๊ฒŒ ์จ์ค˜์•ผ ํ‹€๋ฆฌ์ง€ ์•Š๋Š”๋‹ค. 

 

 

728x90
๋ฐ˜์‘ํ˜•