题目描述
Read problem statements in [Vietnamese],
[Bengali], [Mandarin Chinese], and [Russian] as well.
You are given a tree with $n$ vertices (numbered $1, 2, \dots, n$) and an integer $k$.
A subtree is defined as a connected subgraph of the tree. That is, a subtree is another tree that can be obtained by removing some (possibly none) vertices and all edges incident to those vertices from $T$.
A subset $S$ of vertices is called good if every subtree containing all the nodes in $S$ has at least $k$ nodes.
Find the size of the smallest good subset.
------ Input ------
The first line contains a single integer $T$, the number of test cases. The descriptions of test cases follow.
The first line of each testcase contains two integers, $n$ and $k$.
The next $n-1$ lines each contains two integers $u$, $v$, denoting an edge between vertices $u$ and $v$ of the tree.
------ Output ------
For each test case print in a single line, the minimum size of a good subset.
------ Constraints ------
$1≤ n≤ 10^{5}$
$1 ≤ k ≤ n$
$1 ≤ u, v ≤ n$
The given edges for each test case form a tree.
The sum of $n$ over all test cases is at most $10^{6}$.
------ Subtasks ------
Subtask #1 (30 points): $1 ≤ n ≤ 10^{3}$
Subtask #2 (70 points): original constraints
------ Sample Input ------
2
7 5
1 2
2 3
3 4
3 5
5 6
3 7
6 4
1 2
1 3
1 4
1 5
1 6
------ Sample Output ------
2
3
------ Explanation ------
Test Case $1$:
Consider the set $S = \{1, 6\}$.
The smallest subtree that contains both of the vertices in $S$ is the path between them ($1 \to 2 \to 3 \to 5 \to 6$) which contains $5$ vertices. Hence for $k = 5$, the answer is $2$.
Test Case $2$:
Consider the set $S = \{2, 3, 4\}$.
The smallest subtree that contains these three vertices includes $4$ nodes $\{1, 2, 3, 4\}$.
输入格式
见题面
输出格式
见题面