본문 바로가기

ALGORITHM/백준 With Node.js49

[백준] 10869번 / 사칙연산 / Node.js 문제 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오. 입력 두 자연수 A와 B가 주어진다. (1 ≤ A, B ≤ 10,000) 출력 첫째 줄에 A/B를 출력한다. 실제 정답과 출력값의 절대오차 또는 상대오차가 10-9 이하이면 정답이다. 예제 입력 1 7 3 예제 출력 1 10 4 21 2 1 CODE // readline 모듈을 import const readline = require('readline'); // 인터페이스 객체 생성 // process의 입출력 스트림을 input과 output에 할당 const rl = readline.createInterface({ input: process.stdin, output:.. 2021. 4. 19.
[백준] 1008번 / A/B / Node.js 문제 두 정수 A와 B를 입력받은 다음, A/B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 < A, B < 10) 출력 첫째 줄에 A/B를 출력한다. 실제 정답과 출력값의 절대오차 또는 상대오차가 10-9 이하이면 정답이다. 예제 입력 1 1 3 예제 출력 1 0.33333333333333333333333333333333 예제 입력 2 4 5 예제 출력 2 0.8 CODE // readline 모듈을 import const readline = require('readline'); // 인터페이스 객체 생성 // process의 입출력 스트림을 input과 output에 할당 const rl = readline.createInterface({ input: process.s.. 2021. 4. 19.
[백준] 10998번 / A×B / Node.js 문제 두 정수 A와 B를 입력받은 다음, A×B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 < A, B < 10) 출력 첫째 줄에 A×B를 출력한다. 예제 입력 1 1 2 예제 출력 1 2 예제 입력 2 3 4 예제 출력 2 12 CODE // readline 모듈을 import const readline = require('readline'); // 인터페이스 객체 생성 // process의 입출력 스트림을 input과 output에 할당 const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on('line', function (line) { const inpu.. 2021. 4. 19.
[백준] 1001번 / A-B / Node.js 문제 두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 < A, B < 10) 출력 첫째 줄에 A-B를 출력한다. 예제 입력 1 3 2 예제 출력 1 1 CODE // readline 모듈을 import const readline = require('readline'); // 인터페이스 객체 생성 // process의 입출력 스트림을 input과 output에 할당 const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on('line', function (line) { const input = line.split(' '); co.. 2021. 4. 19.
[백준] 1000번 / A+B / Node.js 문제 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 A와 B가 주어진다. (0 < A, B < 10) 출력 첫째 줄에 A+B를 출력한다. 예제 입력 1 1 2 예제 출력 1 3 CODE // readline 모듈을 import const readline = require('readline'); // 인터페이스 객체 생성 // process의 입출력 스트림을 input과 output에 할당 const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on('line', function (line) { const input = line.split(' '); co.. 2021. 4. 19.
[백준] 10172번 / 개 / Node.js 문제 아래 예제와 같이 개를 출력하시오. 입력 없음. 출력 개를 출력한다. 예제 입력 1 없음 예제 출력 1 |\_/| |q p| /} ( 0 )"""\ |"^"` | ||_/=\\__| CODE console.log('|\\_/|'); console.log('|q p| /}'); console.log('( 0 )"""\\'); console.log('|"^"` |'); console.log('||_/=\\\\__|'); 2021. 4. 19.
[백준] 10171번 / 고양이 / Node.js 문제 아래 예제와 같이 고양이를 출력하시오. 입력 없음. 출력 고양이를 출력한다. 예제 입력 1 없음 예제 출력 1 \ /\ ) ( ') ( / ) \(__)| CODE // 1번 답 // console.log(`\\ /\\`); // console.log(` ) ( ')` ); // console.log(`( / )`); // console.log(` \\(__)|`); // 2번 답 console.log('\\ /\\\n ) ( \')\n( / )\n \\(__)|'); // 3번 답 // console.log('\\ /\\\n', // ') ( \')\n\ // ( / )\n', // '\\(__)|\n'); Comment 위의 코드처럼 console.log를 한 번 OR 네 번 써서 출력할 수 있.. 2021. 4. 19.
[백준] 10718번 / We love kriii / Node.js 문제 ACM-ICPC 인터넷 예선, Regional, 그리고 World Finals까지 이미 2회씩 진출해버린 kriii는 미련을 버리지 못하고 왠지 모르게 올해에도 파주 World Finals 준비 캠프에 참여했다. 대회를 뜰 줄 모르는 지박령 kriii를 위해서 격려의 문구를 출력해주자. 입력 본 문제는 입력이 없다. 출력 두 줄에 걸쳐 "강한친구 대한육군"을 한 줄에 한 번씩 출력한다. 예제 입력 1 없음 예제 출력 1 강한친구 대한육군 강한친구 대한육군 CODE console.log('강한친구 대한육군'); console.log('강한친구 대한육군'); 2021. 4. 19.
[백준] 2557번 / Hello World / Node.js 문제 Hello World!를 출력하시오. 입력 없음 출력 Hello World!를 출력하시오. 예제 입력 1 없음 예제 출력 1 Hello World! CODE console.log('Hello World!'); 2021. 4. 18.