[Baekjoon] 9095๋ฒˆ 1, 2, 3 ๋”ํ•˜๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/9095 9095๋ฒˆ: 1, 2, 3 ๋”ํ•˜๊ธฐ ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค, n์„ 1, 2, 3์˜ ํ•ฉ์œผ๋กœ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐฉ๋ฒ•์˜ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. www.acmicpc.net => ๊ธฐ์กด ๋ฐฑ์ค€ ๋ฌธ์ œ๋ฅผ Javascript๋ฅผ ์ด์šฉํ•ด ํ’€์ดํ•˜์˜€์—ˆ๋Š”๋ฐ, ์ž…์ถœ๋ ฅ๊ด€๋ จํ•ด์„œ ๋งž๊ฒŒ ํ’€์–ด๋„ ํ‹€๋ฆฌ๋‹ค ๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด์„œ ๋ฐฑ์ค€์˜ ๊ฒฝ์šฐ๋Š” python์„ ์‚ฌ์šฉํ•ด์„œ ํ’€์ดํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ•˜์˜€๋‹ค. โ–ถ ์ฝ”๋“œ : # https://www.acmicpc.net/problem/9095 # ๋ฐฑ์ค€ 1, 2, 3 ๋”ํ•˜๊ธฐ T = int(input()) testCase = [] for t in range(T): testCase.append(int(input())) maxNum = max(testCase) dp ..
[BaekJoon] 17626๋ฒˆ Four Squares
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/17626 17626๋ฒˆ: Four Squares ๋ผ๊ทธ๋ž‘์ฃผ๋Š” 1770๋…„์— ๋ชจ๋“  ์ž์—ฐ์ˆ˜๋Š” ๋„ท ํ˜น์€ ๊ทธ ์ดํ•˜์˜ ์ œ๊ณฑ์ˆ˜์˜ ํ•ฉ์œผ๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ฆ๋ช…ํ•˜์˜€๋‹ค. ์–ด๋–ค ์ž์—ฐ์ˆ˜๋Š” ๋ณต์ˆ˜์˜ ๋ฐฉ๋ฒ•์œผ๋กœ ํ‘œํ˜„๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด, 26์€ 52๊ณผ 12์˜ ํ•ฉ์ด๋‹ค; ๋˜ํ•œ 42 + 32 + 1 www.acmicpc.net โ–ถ ์ฝ”๋“œ : const input = require('fs').readFileSync('BaekJoon/testcase.txt').toString().trim().split('\n'); let n = Number(input[0]); const dp = Array(50001); dp[0] = 0; dp[1] = 1; for(let i = 1; i < ..
[BaekJoon] 17219๋ฒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ฐพ๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/17219 17219๋ฒˆ: ๋น„๋ฐ€๋ฒˆํ˜ธ ์ฐพ๊ธฐ ์ฒซ์งธ ์ค„์— ์ €์žฅ๋œ ์‚ฌ์ดํŠธ ์ฃผ์†Œ์˜ ์ˆ˜ N(1 ≤ N ≤ 100,000)๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ฐพ์œผ๋ ค๋Š” ์‚ฌ์ดํŠธ ์ฃผ์†Œ์˜ ์ˆ˜ M(1 ≤ M ≤ 100,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘๋ฒˆ์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ๊ฑธ์ณ ๊ฐ ์ค„์— ์‚ฌ์ดํŠธ ์ฃผ์†Œ์™€ ๋น„๋ฐ€๋ฒˆ www.acmicpc.net โ–ถ ์ฝ”๋“œ : const input = require('fs').readFileSync('BaekJoon/testcase.txt').toString().trim().split('\n'); const [n, m] = input.shift().split(' ').map(Number); const data = new Map(); const reg = new Re..
[BaekJoon] 11724๋ฒˆ ์—ฐ๊ฒฐ ์š”์†Œ์˜ ๊ฐœ์ˆ˜
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/11724 11724๋ฒˆ: ์—ฐ๊ฒฐ ์š”์†Œ์˜ ๊ฐœ์ˆ˜ ์ฒซ์งธ ์ค„์— ์ •์ ์˜ ๊ฐœ์ˆ˜ N๊ณผ ๊ฐ„์„ ์˜ ๊ฐœ์ˆ˜ M์ด ์ฃผ์–ด์ง„๋‹ค. (1 ≤ N ≤ 1,000, 0 ≤ M ≤ N×(N-1)/2) ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ M๊ฐœ์˜ ์ค„์— ๊ฐ„์„ ์˜ ์–‘ ๋์  u์™€ v๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ u, v ≤ N, u ≠ v) ๊ฐ™์€ ๊ฐ„์„ ์€ ํ•œ ๋ฒˆ๋งŒ ์ฃผ www.acmicpc.net โ–ถ ์ฝ”๋“œ : const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); let N = 0; let E = 0; const edges = []; rl.on('li..
[BaekJoon] 2606๋ฒˆ ๋ฐ”์ด๋Ÿฌ์Šค
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/2606 2606๋ฒˆ: ๋ฐ”์ด๋Ÿฌ์Šค ์ฒซ์งธ ์ค„์—๋Š” ์ปดํ“จํ„ฐ์˜ ์ˆ˜๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ปดํ“จํ„ฐ์˜ ์ˆ˜๋Š” 100 ์ดํ•˜์ด๊ณ  ๊ฐ ์ปดํ“จํ„ฐ์—๋Š” 1๋ฒˆ ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ ๋ฒˆํ˜ธ๊ฐ€ ๋งค๊ฒจ์ง„๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๋„คํŠธ์›Œํฌ ์ƒ์—์„œ ์ง์ ‘ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋Š” ์ปดํ“จํ„ฐ ์Œ์˜ ์ˆ˜๊ฐ€ ์ฃผ์–ด www.acmicpc.net โ–ถ ์ฝ”๋“œ: let input = require('fs').readFileSync(`BaekJoon/testcase.txt`).toString().split('\n'); function BFS (graph, start, num){ const visited = Array(num).fill(false); const q = []; let count = 0; const firstN = graph[0..
[BaekJoon] 2579๋ฒˆ ๊ณ„๋‹จ ์˜ค๋ฅด๊ธฐ
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : http://acmicpc.net/problem/2579 2579๋ฒˆ: ๊ณ„๋‹จ ์˜ค๋ฅด๊ธฐ ๊ณ„๋‹จ ์˜ค๋ฅด๊ธฐ ๊ฒŒ์ž„์€ ๊ณ„๋‹จ ์•„๋ž˜ ์‹œ์ž‘์ ๋ถ€ํ„ฐ ๊ณ„๋‹จ ๊ผญ๋Œ€๊ธฐ์— ์œ„์น˜ํ•œ ๋„์ฐฉ์ ๊นŒ์ง€ ๊ฐ€๋Š” ๊ฒŒ์ž„์ด๋‹ค. ๊ณผ ๊ฐ™์ด ๊ฐ๊ฐ์˜ ๊ณ„๋‹จ์—๋Š” ์ผ์ •ํ•œ ์ ์ˆ˜๊ฐ€ ์“ฐ์—ฌ ์žˆ๋Š”๋ฐ ๊ณ„๋‹จ์„ ๋ฐŸ์œผ๋ฉด ๊ทธ ๊ณ„๋‹จ์— ์“ฐ์—ฌ ์žˆ๋Š” ์  www.acmicpc.net โ–ถ ์ฝ”๋“œ : let input = require('fs').readFileSync(`BaekJoon/testcase.txt`).toString().split('\n'); const [N, ...temp] = input; const stairs = temp.map(n => Number(n)); const dp = Array(N).fill(0); dp[0] = stairs[0]; dp[1] = Math.max..
[Baekjoon] 1764 ๋“ฃ๋ณด์žก
ยท
๐Ÿ’ฏ CodingTest/BaekJoon
โ–ถ ๋ฌธ์ œ : https://www.acmicpc.net/problem/1764 1764๋ฒˆ: ๋“ฃ๋ณด์žก ์ฒซ์งธ ์ค„์— ๋“ฃ๋„ ๋ชปํ•œ ์‚ฌ๋žŒ์˜ ์ˆ˜ N, ๋ณด๋„ ๋ชปํ•œ ์‚ฌ๋žŒ์˜ ์ˆ˜ M์ด ์ฃผ์–ด์ง„๋‹ค. ์ด์–ด์„œ ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ๊ฑธ์ณ ๋“ฃ๋„ ๋ชปํ•œ ์‚ฌ๋žŒ์˜ ์ด๋ฆ„๊ณผ, N+2์งธ ์ค„๋ถ€ํ„ฐ ๋ณด๋„ ๋ชปํ•œ ์‚ฌ๋žŒ์˜ ์ด๋ฆ„์ด ์ˆœ์„œ๋Œ€๋กœ ์ฃผ์–ด์ง„๋‹ค. www.acmicpc.net โ–ถ ์ฝ”๋“œ : let input = require('fs').readFileSync(`Computer Science/Alogrithms/๋ฐฑ์ค€JS/testCase.txt`).toString().split('\n'); let data = new Map(); let answer = []; const [n,m] = input[0].split(' ').map(num => parseInt(num..