클릭해서 문제 전체 보기🔼
📖 풀이 코드
const fs = require("fs");
const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";
let input = fs.readFileSync(filePath).toString().trim();
if (input.substring(input.length - 1) != 0) {
console.log("-1");
} else {
let result = "";
let newNum = parseInt(input / 60);
result += parseInt(newNum / 5) + " " + (newNum % 5) + " " + (input % 60) / 10;
console.log(result);
}
📢 풀이 설명
1. 입력값의 마지막 숫자 != 0 ➡ -1 출력
2. 입력값을 60초로 나눈 몫이 K일 때,
2-1. 60초 5 = 300초 = 5분 => 버튼 A 이므로, ParseInt(K / 5) = A
2-2. K를 5개씩 묶고 남은 나머지 => 버튼 B 이므로, K % 5 = B
3. 입력값을 60초로 나누고 남은 나머지 => 버튼 C 10초 이므로, (입력값 % 60) / 10 = C
클릭해서 문제 전체 보기🔼
📖 풀이 코드
const fs = require("fs");
const filePath = process.platform === "linux" ? "/dev/stdin" : "./input.txt";
let input = fs.readFileSync(filePath).toString().trim();
let change = 1000 - input;
let count = 0;
let hundreds = parseInt(change / 100);
let tens = parseInt((change - 100 * hundreds) / 10);
let units = change - 100 * hundreds - 10 * tens;
count += parseInt(hundreds / 5) + (hundreds % 5) + parseInt(tens / 5) + (tens % 5) + parseInt(units / 5) + (units % 5);
console.log(count);
📢 풀이 설명
위 문제인 전자레인지와 비슷한 유형
클릭해서 문제 전체 보기🔼
📖 풀이 코드
ㅎㅎㅎㅎㅎ
📢 풀이 설명
ㅎㅎㅎㅎㅎ
💚 추가 학습~
ㅎㅎㅎㅎㅎ
좋은 정보 감사합니다