본문 바로가기
SMALL

javascript16

백준 Node.js(자바스크립트) 1267번 핸드폰 요금 const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const input = fs.readFileSync(filePath).toString().split("\n"); let call = input.shift(); let calls = input[0].split(" ").map(a => Number(a)); callBill(calls); function callBill(B) { let m = 0; let y = 0; for (let i = 0; i < B.length; i++) { y += B[i] % 30 === 0 ? (B[i] / 30 + 1) * 10 : Math.c.. 2021. 9. 21.
백준 Node.js(자바스크립트) 2446문제 별찍기 -9 const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const input = +fs.readFileSync(filePath).toString(); star(input); function star(num) { for (let i = 0; i < num * 2 - 1; i++) { let stars = ""; if (i < num) { for (let j = 0; j < i; j++) { stars += " "; } for (let k = 0; k < (num - i) * 2 - 1; k++) { stars += "*"; } console.log(stars); } else {.. 2021. 9. 20.
백준 Node.js(자바스크립트) 1011문제 Fly me to the Alpha Centauri const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; let input = fs.readFileSync(filePath).toString().split('\n'); let testCase = input[0]; solution(); function solution() { for (let i = 1; i > √n이 자연수일 경우에는 √n + √n-1을 하면 됨 else >> √n이 딱 떨어지지않을경우 n의제곱 ~ (n+1)의 제곱 사이에 있는 건데 아무 수나 넣고 적어보니 √n를 2곱하고 소수점을 뺐다. 2021. 9. 10.
백준 Node.js(자바스크립트) 2839번 설탕배달 const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; let sugar = Number(fs.readFileSync(filePath).toString()); solution(); function solution() { let smallBag = 0; while (true) { if (sugar % 5 == 0) { console.log(sugar / 5 + smallBag); break; } else if (sugar / 5 < 0) { console.log(-1); break; } else { sugar -= 3; smallBag++; } } } sugar % 5 == 0.. 2021. 9. 10.
LIST