Algorithms/Baekjoon

    [JS] ๋ฐฑ์ค€ 2884๋ฒˆ : ์•Œ๋žŒ์‹œ๊ณ„

    [JS] ๋ฐฑ์ค€ 2884๋ฒˆ : ์•Œ๋žŒ์‹œ๊ณ„

    Question ๋ฐฑ์ค€ 2884๋ฒˆ : ์•Œ๋žŒ์‹œ๊ณ„ 2884๋ฒˆ: ์•Œ๋žŒ ์‹œ๊ณ„ ์ƒ๊ทผ์ด๋Š” ๋งค์ผ ์•„์นจ ์•Œ๋žŒ์„ ๋“ฃ๊ณ  ์ผ์–ด๋‚œ๋‹ค. ์•Œ๋žŒ์„ ๋“ฃ๊ณ  ๋ฐ”๋กœ ์ผ์–ด๋‚˜๋ฉด ๋‹คํ–‰์ด๊ฒ ์ง€๋งŒ, ํ•ญ์ƒ ์กฐ๊ธˆ๋งŒ ๋” ์ž๋ ค๋Š” ๋งˆ์Œ ๋•Œ๋ฌธ์— ๋งค์ผ ํ•™๊ต๋ฅผ ์ง€๊ฐํ•˜๊ณ  ์žˆ๋‹ค. ์ƒ๊ทผ์ด๋Š” ๋ชจ๋“  ๋ฐฉ๋ฒ•์„ ๋™์›ํ•ด๋ณด์•˜์ง€๋งŒ, www.acmicpc.net My Code const input = require('fs').readFileSync('dev/stdin').toString().trim().split(' '); let num1 = Number(input[0]); let num2 = Number(input[1]); if (num2 < 45) { num1 -= 1; num2 += 15; } else{ num2 -= 45; } console.log(`${num1} ${num2}..

    [JS] ๋ฐฑ์ค€ 15552๋ฒˆ : ๋น ๋ฅธ A + B

    [JS] ๋ฐฑ์ค€ 15552๋ฒˆ : ๋น ๋ฅธ A + B

    Question ๋ฐฑ์ค€ 1552๋ฒˆ : ๋น ๋ฅธ A + B 15552๋ฒˆ: ๋น ๋ฅธ A+B ์ฒซ ์ค„์— ํ…Œ์ŠคํŠธ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. T๋Š” ์ตœ๋Œ€ 1,000,000์ด๋‹ค. ๋‹ค์Œ T์ค„์—๋Š” ๊ฐ๊ฐ ๋‘ ์ •์ˆ˜ A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. A์™€ B๋Š” 1 ์ด์ƒ, 1,000 ์ดํ•˜์ด๋‹ค. www.acmicpc.net My Code let input = require('fs').readFileSync('dev/stdin').toString().split('\n'); for (let i = 1; i

    [JS] ๋ฐฑ์ค€ 2480๋ฒˆ : ์ฃผ์‚ฌ์œ„ ์„ธ๊ฐœ

    [JS] ๋ฐฑ์ค€ 2480๋ฒˆ : ์ฃผ์‚ฌ์œ„ ์„ธ๊ฐœ

    Question 1์—์„œ๋ถ€ํ„ฐ 6๊นŒ์ง€์˜ ๋ˆˆ์„ ๊ฐ€์ง„ 3๊ฐœ์˜ ์ฃผ์‚ฌ์œ„๋ฅผ ๋˜์ ธ์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ทœ์น™์— ๋”ฐ๋ผ ์ƒ๊ธˆ์„ ๋ฐ›๋Š” ๊ฒŒ์ž„์ด ์žˆ๋‹ค. ๊ฐ™์€ ๋ˆˆ์ด 3๊ฐœ๊ฐ€ ๋‚˜์˜ค๋ฉด 10,000์›+(๊ฐ™์€ ๋ˆˆ)×1,000์›์˜ ์ƒ๊ธˆ์„ ๋ฐ›๊ฒŒ ๋œ๋‹ค. ๊ฐ™์€ ๋ˆˆ์ด 2๊ฐœ๋งŒ ๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ์—๋Š” 1,000์›+(๊ฐ™์€ ๋ˆˆ)×100์›์˜ ์ƒ๊ธˆ์„ ๋ฐ›๊ฒŒ ๋œ๋‹ค. ๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ์ด ๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ์—๋Š” (๊ทธ ์ค‘ ๊ฐ€์žฅ ํฐ ๋ˆˆ)×100์›์˜ ์ƒ๊ธˆ์„ ๋ฐ›๊ฒŒ ๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 3๊ฐœ์˜ ๋ˆˆ 3, 3, 6์ด ์ฃผ์–ด์ง€๋ฉด ์ƒ๊ธˆ์€ 1,000+3×100์œผ๋กœ ๊ณ„์‚ฐ๋˜์–ด 1,300์›์„ ๋ฐ›๊ฒŒ ๋œ๋‹ค. ๋˜ 3๊ฐœ์˜ ๋ˆˆ์ด 2, 2, 2๋กœ ์ฃผ์–ด์ง€๋ฉด 10,000+2×1,000 ์œผ๋กœ ๊ณ„์‚ฐ๋˜์–ด 12,000์›์„ ๋ฐ›๊ฒŒ ๋œ๋‹ค. 3๊ฐœ์˜ ๋ˆˆ์ด 6, 2, 5๋กœ ์ฃผ์–ด์ง€๋ฉด ๊ทธ์ค‘ ๊ฐ€์žฅ ํฐ ๊ฐ’์ด 6์ด๋ฏ€๋กœ 6×100์œผ๋กœ ๊ณ„์‚ฐ๋˜์–ด 600์›์„ ์ƒ..

    [JS] ๋ฐฑ์ค€ 10950๋ฒˆ : A + B - 3

    [JS] ๋ฐฑ์ค€ 10950๋ฒˆ : A + B - 3

    Question ๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. 10950๋ฒˆ: A+B - 3 ๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. www.acmicpc.net My Code let input = require('fs').readFileSync('dev/stdin').toString().split('\n'); for (let i = 1; i < input.length; i ++) { let arr = input[i].split(' ').map(Number); console.log(arr[0] + arr[1]); } ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค ์™œ ํ‹€๋ ธ์ง€? ๊ตฌ๊ธ€๋ง ํ•ด๋ณด๋‹ˆ๊นŒ input.length ์‚ฌ์šฉ์‹œ ๋ฐ˜๋ณต๋ฌธ์ด ๋Œ๋•Œ๋งˆ๋‹ค ๊ธธ์ด๋ฅผ ๊ณ„์‚ฐํ•ด์„œ ์„ฑ๋Šฅ์ €ํ•˜๋ฅผ ๋ถˆ๋Ÿฌ์˜จ๋‹ค๊ณ  ..