본문 바로가기

728x90

JavaScript

[Node.js]백준 2156번 - 포도주 시식 const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(Number(line)); }) .on('close', () => { const [,...wine] = input; if(wine.length < 2) { console.log(wine[0]); process.exit(); } else if (wine.length < 2) { console.log(wine[0] + wine[1]); process.exit(); } const memo = .. 더보기
[node.js] 백준 1463번 1로 만들기 const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(Number(line)); }) .on('close', () => { const [n] = input; const memo = { 0: 0, 1: 0, } for (let i = 2; i 더보기
[node.js] 백준 10844번 쉬운 계단 수 const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(Number(line)); }) .on('close', () => { const [n] = input; const memo = [...new Array(n + 1).keys()].map(() => []); memo[1] = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]; memo[2] = [1, 1, 2, 2, 2, 2, 2, 2, 2, 1]; for(let i = 3; i { .. 더보기
[Node.js]백준 10872번 /** * @link https://www.acmicpc.net/problem/10872 * @since 2021/05/09 */ const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(Number(line)); }) .on('close', () => { const [num] = input; // solution1 // solution1(num); // solution2 solution2(num); process.exit(); }); func.. 더보기
[Node.js]백준 1316번 link: www.acmicpc.net/problem/1316 1316번: 그룹 단어 체커 그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때 www.acmicpc.net const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(line); }) .on('close', () =.. 더보기
[Node.js] 백준 11720번 link: www.acmicpc.net/problem/11720 11720번: 숫자의 합 첫째 줄에 숫자의 개수 N (1 ≤ N ≤ 100)이 주어진다. 둘째 줄에 숫자 N개가 공백없이 주어진다. www.acmicpc.net const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(line); }) .on('close', () => { const [, str] = input; const numArr = str.split('').map(Numbe.. 더보기
[Node.js] 백준 11654번 Link: www.acmicpc.net/problem/11654 11654번: 아스키 코드 알파벳 소문자, 대문자, 숫자 0-9중 하나가 주어졌을 때, 주어진 글자의 아스키 코드값을 출력하는 프로그램을 작성하시오. www.acmicpc.net const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const input = []; rl.on('line', (line) => { input.push(line); }) .on('close', () => { const [str] = input; console.log(str.charCodeAt(0)).. 더보기

728x90