๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
[๋ฐฑ์ค€][Node.js] 2738๋ฒˆ : ํ–‰๋ ฌ ๋ง์…ˆ Algorithm - ํ–‰๋ ฌ ๋ง์…ˆ - ๋ฌธ์ œ N*Mํฌ๊ธฐ์˜ ๋‘ ํ–‰๋ ฌ A์™€ B๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ๋‘ ํ–‰๋ ฌ์„ ๋”ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = []; rl.on("line", function (line) { input.push(line.toString()); }).on("close", function () { let number = input .shift() .split(" ") .map((el) => Number(el)); input = input.m.. 2021. 9. 9.
[๋ฐฑ์ค€][Node.js] 2720๋ฒˆ : ์„ธํƒ์†Œ ์‚ฌ์žฅ ๋™ํ˜ Algorithm - ์„ธํƒ์†Œ ์‚ฌ์žฅ ๋™ํ˜ - ๋ฌธ์ œ ๋ฏธ๊ตญ์œผ๋กœ ์œ ํ•™๊ฐ„ ๋™ํ˜์ด๋Š” ์„ธํƒ์†Œ๋ฅผ ์šด์˜ํ•˜๊ณ  ์žˆ๋‹ค. ๋™ํ˜์ด๋Š” ์ตœ๊ทผ์— ์•„๋ฅด๋ฐ”์ดํŠธ๋กœ ๊ณ ๋“ฑํ•™์ƒ ๋ฆฌ์•”์„ ์ฑ„์šฉํ–ˆ๋‹ค. ๋™ํ˜์ด๋Š” ๋ฆฌ์•”์—๊ฒŒ ์‹ค๋งํ–ˆ๋‹ค. ๋ฆฌ์•”์€ ๊ฑฐ์Šค๋ฆ„๋ˆ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ž๊พธ ์‹ค์ˆ˜ํ•œ๋‹ค. ์‹ฌ์ง€์–ด $0.5๋‹ฌ๋Ÿฌ๋ฅผ ์ค˜์•ผํ•˜๋Š” ๊ฒฝ์šฐ์— ๊ฑฐ์Šค๋ฆ„๋ˆ์œผ๋กœ $5๋‹ฌ๋Ÿฌ๋ฅผ ์ฃผ๋Š”๊ฒƒ์ด๋‹ค! ์–ด์ฉ”์ˆ˜ ์—†์ด ๋›ฐ์–ด๋‚œ ์ฝ”๋”ฉ ์‹ค๋ ฅ์„ ๋ฐœํœ˜ํ•ด ๋ฆฌ์•”์„ ๋„์™€์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋ ค๊ณ  ํ•˜์ง€๋งŒ, ๋””์•„๋ธ”๋กœ๋ฅผ ํ•˜๋Š๋ผ ์ฝ”๋”ฉํ•  ์‹œ๊ฐ„์ด ์—†์–ด์„œ ์ด ๋ฌธ์ œ๋ฅผ ์ฝ๊ณ  ์žˆ๋Š” ์—ฌ๋Ÿฌ๋ถ„์ด ๋Œ€์‹  ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. ๊ฑฐ์Šค๋ฆ„๋ˆ์˜ ์•ก์ˆ˜๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ๋ฆฌ์•”์ด ์ค˜์•ผํ•  ์ฟผํ„ฐ(Quarter, $0.25)์˜ ๊ฐœ์ˆ˜, ๋‹ค์ž„(Dime, $0.10)์˜ ๊ฐœ์ˆ˜, ๋‹ˆ์ผˆ(Nickel, $0.05)์˜ ๊ฐœ์ˆ˜, ํŽ˜๋‹ˆ(Penny, $0.01)์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ๊ฑฐ.. 2021. 9. 8.
[๋ฐฑ์ค€][Node.js] 2711๋ฒˆ : ์˜คํƒ€๋งจ ๊ณ ์ฐฝ์˜ Algorithm - ์˜คํƒ€๋งจ ๊ณ ์ฐฝ์˜ - ๋ฌธ์ œ ๊ณ ์ฐฝ์˜์€ ๋งจ๋‚  ์˜คํƒ€๋ฅผ ๋‚ธ๋‹ค. ์ฐฝ์˜์ด๊ฐ€ ์˜คํƒ€๋ฅผ ๋‚ธ ๋ฌธ์žฅ๊ณผ ์˜คํƒ€๋ฅผ ๋‚ธ ์œ„์น˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์˜คํƒ€๋ฅผ ์ง€์šด ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ฐฝ์˜์ด๋Š” ์˜คํƒ€๋ฅผ ๋ฐ˜๋“œ์‹œ 1๊ฐœ๋งŒ ๋‚ธ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ let fs = require("fs"); let input = fs.readFileSync("/dev/stdin") .toString() .split("\n"); for (let i = 1; i 2021. 9. 7.
[๋ฐฑ์ค€][Node.js] 2675๋ฒˆ : ๋ฌธ์ž์—ด ๋ฐ˜๋ณต Algorithm - ๋ฌธ์ž์—ด ๋ฐ˜๋ณต - ๋ฌธ์ œ ๋ฌธ์ž์—ด S๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ํ›„์—, ๊ฐ ๋ฌธ์ž๋ฅผ R๋ฒˆ ๋ฐ˜๋ณตํ•ด ์ƒˆ ๋ฌธ์ž์—ด P๋ฅผ ๋งŒ๋“  ํ›„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ฆ‰, ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ž๋ฅผ R๋ฒˆ ๋ฐ˜๋ณตํ•˜๊ณ , ๋‘ ๋ฒˆ์งธ ๋ฌธ์ž๋ฅผ R๋ฒˆ ๋ฐ˜๋ณตํ•˜๋Š” ์‹์œผ๋กœ P๋ฅผ ๋งŒ๋“ค๋ฉด ๋œ๋‹ค. S์—๋Š” QR Code "alphanumeric" ๋ฌธ์ž๋งŒ ๋“ค์–ด์žˆ๋‹ค. QR Code "alphanumeric" ๋ฌธ์ž๋Š” 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\$%*+-./: ์ด๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ let fs = require("fs"); let input = fs.readFileSync("/dev/stdin").toString().trim().split("\n"); for (let i = 1; i < input.length; i+.. 2021. 9. 6.
[๋ฐฑ์ค€][Node.js] 2667๋ฒˆ : ๋‹จ์ง€๋ฒˆํ˜ธ๋ถ™์ด๊ธฐ Algorithm - ๋‹จ์ง€๋ฒˆํ˜ธ๋ถ™์ด๊ธฐ - ๋ฌธ์ œ ๊ณผ ๊ฐ™์ด ์ •์‚ฌ๊ฐํ˜• ๋ชจ์–‘์˜ ์ง€๋„๊ฐ€ ์žˆ๋‹ค. 1์€ ์ง‘์ด ์žˆ๋Š” ๊ณณ์„, 0์€ ์ง‘์ด ์—†๋Š” ๊ณณ์„ ๋‚˜ํƒ€๋‚ธ๋‹ค. ์ฒ ์ˆ˜๋Š” ์ด ์ง€๋„๋ฅผ ๊ฐ€์ง€๊ณ  ์—ฐ๊ฒฐ๋œ ์ง‘์˜ ๋ชจ์ž„์ธ ๋‹จ์ง€๋ฅผ ์ •์˜ํ•˜๊ณ , ๋‹จ์ง€์— ๋ฒˆํ˜ธ๋ฅผ ๋ถ™์ด๋ ค ํ•œ๋‹ค. ์—ฌ๊ธฐ์„œ ์—ฐ๊ฒฐ๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์€ ์–ด๋–ค ์ง‘์ด ์ขŒ์šฐ, ํ˜น์€ ์•„๋ž˜์œ„๋กœ ๋‹ค๋ฅธ ์ง‘์ด ์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ ๋งํ•œ๋‹ค. ๋Œ€๊ฐ์„ ์ƒ์— ์ง‘์ด ์žˆ๋Š” ๊ฒฝ์šฐ๋Š” ์—ฐ๊ฒฐ๋œ ๊ฒƒ์ด ์•„๋‹ˆ๋‹ค. ๋Š” ์„ ๋‹จ์ง€๋ณ„๋กœ ๋ฒˆํ˜ธ๋ฅผ ๋ถ™์ธ ๊ฒƒ์ด๋‹ค. ์ง€๋„๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๋‹จ์ง€์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๊ณ , ๊ฐ ๋‹จ์ง€์— ์†ํ•˜๋Š” ์ง‘์˜ ์ˆ˜๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜์—ฌ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process... 2021. 9. 5.
[๋ฐฑ์ค€][Node.js] 2609๋ฒˆ : ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ Algorithm - ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ - ๋ฌธ์ œ ๋‘ ๊ฐœ์˜ ์ž์—ฐ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ ๊ณต๋ฐฐ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input; rl.on("line", function (line) { input = line .toString() .split(" ") .map((el) => +el); }).on("close", function () { let result = []; // ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜, ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ let big = Math.max(.. 2021. 9. 4.