๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
[๋ฐฑ์ค€][Node.js] 5988๋ฒˆ : ํ™€์ˆ˜์ผ๊นŒ ์ง์ˆ˜์ผ๊นŒ Algorithm - ํ™€์ˆ˜์ผ๊นŒ ์ง์ˆ˜์ผ๊นŒ - ๋ฌธ์ œ ์ง์ด ์—†๋Š” ๊ฒฝ์žฌ๋Š” ๋งค์ผ ํ™€๋กœ ์žˆ๋‹ค๋ณด๋‹ˆ ํ™€์ˆ˜๋ฅผ ํŒ๋ณ„ํ•  ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ์ด ์ƒ๊ฒผ๋‹ค. ์ฐฝ์‹์ด๋Š” ๊ฒฝ์žฌ์˜ ๋ง์ด ์‚ฌ์‹ค์ธ์ง€ ๊ทธ ๋Šฅ๋ ฅ์„ ์‹œํ—˜ํ•ด๋ณด๋ ค ํ•œ๋‹ค. ์ฐฝ์‹์ด์˜ ์˜์‹ฌ์ด ๋์ด ์—†์„ ๊ฒƒ ๊ฐ™์•„ N๊ฐœ๋งŒ ํ™•์ธํ•˜๊ธฐ๋กœ ์ •ํ–ˆ๋‹ค. N๊ฐœ์˜ ์ •์ˆ˜๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ํ™€์ˆ˜์ธ์ง€ ์ง์ˆ˜์ธ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด ๊ฒฝ์žฌ์˜ ๋Šฅ๋ ฅ์„ ๊ฒ€์ฆํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋„์™€์ฃผ์ž. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = []; rl.on("line", function (line) { input.push(.. 2021. 12. 1.
[๋ฐฑ์ค€][Node.js] 5717๋ฒˆ : ์ƒ๊ทผ์ด์˜ ์นœ๊ตฌ๋“ค Algorithm - ์ƒ๊ทผ์ด์˜ ์นœ๊ตฌ๋“ค - ๋ฌธ์ œ ์ƒ๊ทผ์ด์˜ ๋‚จ์ž ์นœ๊ตฌ์˜ ์ˆ˜์™€ ์—ฌ์ž ์นœ๊ตฌ์˜ ์ˆ˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์นœ๊ตฌ๋Š” ์ด ๋ช‡ ๋ช…์ธ์ง€ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = []; let result = []; rl.on("line", function (line) { input.push(line.toString()); }).on("close", function () { input = input.map((el) => el.split(" ").map((el).. 2021. 11. 30.
[๋ฐฑ์ค€][Node.js] 5622๋ฒˆ : ๋‹ค์ด์–ผ Algorithm - ๋‹ค์ด์–ผ - ๋ฌธ์ œ ์ƒ๊ทผ์ด์˜ ํ• ๋จธ๋‹ˆ๋Š” ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์˜ค๋ž˜๋œ ๋‹ค์ด์–ผ ์ „ํ™”๊ธฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์ „ํ™”๋ฅผ ๊ฑธ๊ณ  ์‹ถ์€ ๋ฒˆํ˜ธ๊ฐ€ ์žˆ๋‹ค๋ฉด, ์ˆซ์ž๋ฅผ ํ•˜๋‚˜๋ฅผ ๋ˆ„๋ฅธ ๋‹ค์Œ์— ๊ธˆ์† ํ•€์ด ์žˆ๋Š” ๊ณณ ๊นŒ์ง€ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ ๋Œ๋ ค์•ผ ํ•œ๋‹ค. ์ˆซ์ž๋ฅผ ํ•˜๋‚˜ ๋ˆ„๋ฅด๋ฉด ๋‹ค์ด์–ผ์ด ์ฒ˜์Œ ์œ„์น˜๋กœ ๋Œ์•„๊ฐ€๊ณ , ๋‹ค์Œ ์ˆซ์ž๋ฅผ ๋ˆ„๋ฅด๋ ค๋ฉด ๋‹ค์ด์–ผ์„ ์ฒ˜์Œ ์œ„์น˜์—์„œ ๋‹ค์‹œ ๋Œ๋ ค์•ผ ํ•œ๋‹ค. ์ˆซ์ž 1์„ ๊ฑธ๋ ค๋ฉด ์ด 2์ดˆ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. 1๋ณด๋‹ค ํฐ ์ˆ˜๋ฅผ ๊ฑฐ๋Š”๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„์€ ์ด๋ณด๋‹ค ๋” ๊ฑธ๋ฆฌ๋ฉฐ, ํ•œ ์นธ ์˜†์— ์žˆ๋Š” ์ˆซ์ž๋ฅผ ๊ฑธ๊ธฐ ์œ„ํ•ด์„  1์ดˆ์”ฉ ๋” ๊ฑธ๋ฆฐ๋‹ค. ์ƒ๊ทผ์ด์˜ ํ• ๋จธ๋‹ˆ๋Š” ์ „ํ™” ๋ฒˆํ˜ธ๋ฅผ ๊ฐ ์ˆซ์ž์— ํ•ด๋‹นํ•˜๋Š” ๋ฌธ์ž๋กœ ์™ธ์šด๋‹ค. ์ฆ‰, ์–ด๋–ค ๋‹จ์–ด๋ฅผ ๊ฑธ ๋•Œ, ๊ฐ ์•ŒํŒŒ๋ฒณ์— ํ•ด๋‹นํ•˜๋Š” ์ˆซ์ž๋ฅผ ๊ฑธ๋ฉด ๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, UNUCIC๋Š” 868242์™€ ๊ฐ™๋‹ค. ํ• ๋จธ๋‹ˆ๊ฐ€ ์™ธ์šด ๋‹จ์–ด๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ด .. 2021. 11. 29.
[๋ฐฑ์ค€][Node.js] 5598๋ฒˆ : ์นด์ด์‚ฌ๋ฅด ์•”ํ˜ธ Algorithm - ์นด์ด์‚ฌ๋ฅด ์•”ํ˜ธ - ๋ฌธ์ œ ๊ฐ€์ด์šฐ์Šค ์œจ๋ฆฌ์šฐ์Šค ์นด์ด์‚ฌ๋ฅด(Gaius Julius Caesar)๋Š” ๊ณ ๋Œ€ ๋กœ๋งˆ ๊ตฐ์ธ์ด์ž ์ •์น˜๊ฐ€์˜€๋‹ค. ์นด์ด์‚ฌ๋ฅด๋Š” ๋น„๋ฐ€์Šค๋Ÿฝ๊ฒŒ ํŽธ์ง€๋ฅผ ์“ธ ๋•Œ, 'A'๋ฅผ 'D๋กœ', 'B'๋ฅผ 'E'๋กœ, 'C'๋ฅผ 'F'๋กœ... ์ด๋Ÿฐ ์‹์œผ๋กœ ์•ŒํŒŒ๋ฒณ ๋ฌธ์ž๋ฅผ 3๊ฐœ์”ฉ ๊ฑด๋„ˆ๋›ฐ์–ด ์ ์—ˆ๋‹ค๊ณ  ํ•œ๋‹ค. 26๊ฐœ์˜ ๋Œ€๋ฌธ์ž ์•ŒํŒŒ๋ฒณ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ๋‹จ์–ด๋ฅผ ์นด์ด์‚ฌ๋ฅด ์•”ํ˜ธ ํ˜•์‹์œผ๋กœ 3๋ฌธ์ž๋ฅผ ์˜ฎ๊ฒจ ๊ฒน์น˜์ง€ ์•Š๊ฒŒ ๋‚˜์—ดํ•˜์—ฌ ์–ป์€ ์นด์ด์‚ฌ๋ฅด ๋‹จ์–ด๊ฐ€ ์žˆ๋‹ค. ์ด ์นด์ด์‚ฌ๋ฅด ๋‹จ์–ด๋ฅผ ์›๋ž˜ ๋‹จ์–ด๋กœ ๋Œ๋ ค๋†“๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ๊ฐ ๋ฌธ์ž๋ณ„๋กœ ๋ณ€ํ™˜ ์ „๊ณผ ๋ณ€ํ™˜ ํ›„๋ฅผ ๋‚˜ํƒ€๋‚ธ ๊ฑด ์•„๋ž˜์™€ ๊ฐ™๋‹ค. ๋ณ€ํ™˜์ „ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ๋ณ€ํ™˜ํ›„ D E F G H I J K L M N O P Q.. 2021. 11. 28.
[๋ฐฑ์ค€][Node.js] 5597๋ฒˆ : ๊ณผ์ œ ์•ˆ ๋‚ด์‹  ๋ถ„..? Algorithm - ๊ณผ์ œ ์•ˆ ๋‚ด์‹  ๋ถ„..? - ๋ฌธ์ œ X๋Œ€ํ•™ M๊ต์ˆ˜๋‹˜์€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ˆ˜์—…์„ ๋งก๊ณ  ์žˆ๋‹ค. ๊ต์‹ค์—” ํ•™์ƒ์ด 30๋ช…์ด ์žˆ๋Š”๋ฐ, ํ•™์ƒ ๋ช…๋ถ€์—” ๊ฐ ํ•™์ƒ๋ณ„๋กœ 1๋ฒˆ๋ถ€ํ„ฐ 30๋ฒˆ๊นŒ์ง€ ์ถœ์„๋ฒˆํ˜ธ๊ฐ€ ๋ถ™์–ด ์žˆ๋‹ค. ๊ต์ˆ˜๋‹˜์ด ๋‚ด์ค€ ํŠน๋ณ„๊ณผ์ œ๋ฅผ 28๋ช…์ด ์ œ์ถœํ–ˆ๋Š”๋ฐ, ๊ทธ ์ค‘์—์„œ ์ œ์ถœ ์•ˆ ํ•œ ํ•™์ƒ 2๋ช…์˜ ์ถœ์„๋ฒˆํ˜ธ๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ 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());.. 2021. 11. 27.
[๋ฐฑ์ค€][Node.js] 5586๋ฒˆ : JOI์™€ IOI Algorithm - JOI์™€ IOI - ๋ฌธ์ œ ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง€๋Š” ๋ฌธ์ž์—ด์—์„œ ์—ฐ์†์œผ๋กœ 3๊ฐœ์˜ ๋ฌธ์ž๊ฐ€ JOI ๋˜๋Š” IOI์ธ ๊ณณ์ด ๊ฐ๊ฐ ๋ช‡ ๊ฐœ ์žˆ๋Š”์ง€ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ๋ฌธ์ž์—ด์€ ์•ŒํŒŒ๋ฒณ ๋Œ€๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์•„๋ž˜์™€ ๊ฐ™์ด "JOIOIOI"์—๋Š” JOI๊ฐ€ 1๊ฐœ, IOI๊ฐ€ 2๊ฐœ ์žˆ๋‹ค. ์ž…์ถœ๋ ฅ ์˜ˆ์‹œ ๋ฌธ์ œ ํ’€๊ธฐ let fs = require("fs"); let input = fs.readFileSync("/dev/stdin").toString(); let joi = 0; let ioi = 0; for (let i = 0; i < input.length; i++) { if (input.slice(i, i + 3) === 'JOI') joi++; else if (input.slice(i, i +.. 2021. 11. 26.