From 7de948add19c15304b231c848f68f08d03011654 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Tue, 15 Jul 2025 22:14:46 +0900 Subject: [PATCH] 20250715 baekjoon --- code_study/Baekjoon/python/2606.py | 17 +++++++++++++++++ code_study/Baekjoon/python/9095.py | 7 +++++++ code_study/Baekjoon/ts/2606.ts | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 code_study/Baekjoon/python/2606.py create mode 100644 code_study/Baekjoon/python/9095.py create mode 100644 code_study/Baekjoon/ts/2606.ts diff --git a/code_study/Baekjoon/python/2606.py b/code_study/Baekjoon/python/2606.py new file mode 100644 index 0000000..5c5beaf --- /dev/null +++ b/code_study/Baekjoon/python/2606.py @@ -0,0 +1,17 @@ +N = int(input()) +link = [[] for _ in range(N+1)] +visited = [False] * (N+1) + +for _ in range(int(input())): + a, b = map(int, input().split()) + link[a].append(b) + link[b].append(a) + +def dfs(now) : + visited[now] = True + for nt in link[now] : + if not visited[nt] : + dfs(nt) + +dfs(1) +print(visited.count(True)-1) \ No newline at end of file diff --git a/code_study/Baekjoon/python/9095.py b/code_study/Baekjoon/python/9095.py new file mode 100644 index 0000000..8855ed2 --- /dev/null +++ b/code_study/Baekjoon/python/9095.py @@ -0,0 +1,7 @@ +dp = [0]*11 +dp[1:3] = [1,2,4] +for i in range(4,11): + dp[i] = dp[i-1] + dp[i-2] + dp[i-3] + +for _ in range(int(input())): + print(dp[int(input())]) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/2606.ts b/code_study/Baekjoon/ts/2606.ts new file mode 100644 index 0000000..c8e07b1 --- /dev/null +++ b/code_study/Baekjoon/ts/2606.ts @@ -0,0 +1,24 @@ +export {}; + +const input: string[] = require("fs").readFileSync(0, "utf8").toString().trim().split('\n') +let link = Array.from({length : Number(input[0])+1}, () => []); +let visited = new Array(Number(input[0])+1).fill(false); +input.slice(2).forEach(v => { + const [a,b] = v.split(" ").map(Number); + link[a].push(b); + link[b].push(a); +}); + +const dfs = (now: number) => { + visited[now] = true; + for(let nt of link[now]){ + if(!visited[nt]){ + dfs(nt); + } + } +} + +dfs(1); +let count: number = 0; +visited.forEach((v)=>{if(v) count++;}); +console.log(count-1); \ No newline at end of file