본문 바로가기
728x90

배움 기록64

[알고리즘] 백준 2480번 : JavaScript(Node.js) 풀기 📌 문제 📌 풀이 const input = require('fs').readFileSync('/dev/stdin').toString().split(' ').map(Number).sort(); const [a,b,c] = input; if (a === b && b === c) { // 세 숫자가 같을 경우 console.log(10000 + a * 1000); } else if (a === b || b === c) { // 정렬을 했기 때문에 두 가지 경우의 수가 됨 if (a === b) { console.log(1000 + a * 100); } else if (b === c) { console.log(1000 + b * 100); } } else if (a !== b && b !== c) { // 세 .. 2023. 5. 29.
[알고리즘] 백준 2884번 : JavaScript(Node.js) 풀기 📌 문제 📌 풀이 const input = require('fs').readFileSync('/dev/stdin').toString().split(' '); let H = parseInt(input[0]); let M = parseInt(input[1]); if (M < 45) { H -= 1; M = 60 + M - 45; } else { M -= 45; } if (H < 0) { H = 23; } console.log(H, M); M(분)이 45보다 작다면, H에서 1H(=60M)을 빼서 계산해야 하므로 위와 같이 H, M을 계산하였다. M(분)이 45보다 크다면, H에서 떼어서 계산할 필요가 없으므로 M - 45만 계산하면 된다. M(분)이 45보다 작다는 조건에서 H에서 1H을 뺄 때, H가 -(.. 2023. 5. 29.
[알고리즘] 백준 9498번 : JavaScript(Node.js) 풀기 📌 문제 📌 풀이 const input = require('fs').readFileSync('/dev/stdin').toString(); const score = parseInt(input); if (score >= 90 && score = 80 && score = 70 && scroe = 60 && score 2023. 5. 21.
[알고리즘] 백준 11382번 : JavaScript(Node.js) 풀기 📌 문제 📌 풀이 const input = require('fs').readFileSync('/dev/stdin').toString().split(' '); const a = parseInt(input[0]); const b = parseInt(input[1]); const c = parseInt(input[2]); console.log(a+b+c); 다른 분들은 어떻게 풀었는지 궁금해서 찾아보던 중 reduce()를 사용한 풀이를 접하고 정리해보고자 합니다. const fs = require('fs'); const input = fs.readFileSync("/dev/stdin").toString().trim().split(" ").map(Number); const answer = input.reduc.. 2023. 5. 14.
728x90
반응형