본문 바로가기
SMALL

codingTest5

백준 1476번 날짜 계산 https://www.acmicpc.net/problem/1476 let input = require('fs').readFileSync('/dev/stdin').toString().trim().split(' ').map(e => +e); let [e, s, m] = [...input]; let count = 1; while (1) { if ( (count - e) % 15 === 0 && (count - s) % 28 === 0 && (count - m) % 19 === 0 ) { console.log(count); break; } count++; } 코드보다 문제 이해하는게 더 어려운거같은데... 뭐지? 근데 저 코드로 제출하면 메모리초과가 뜬다. 브루트하지않은녀석 https://kscodebase.t.. 2022. 7. 4.
백준 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(자바스크립트) 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