题库练习 K-Set Tree
← 上一题 下一题 →

A15088 | K-Set Tree

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given a tree $G$ with $n$ vertices and an integer $k$ . The vertices of the tree are numbered from $1$ to $n$ .

For a vertex $r$ and a subset $S$ of vertices of $G$ , such that $|S| = k$ , we define $f(r, S)$ as the size of the smallest rooted subtree containing all vertices in $S$ when the tree is rooted at $r$ . A set of vertices $T$ is called a rooted subtree, if all the vertices in $T$ are connected, and for each vertex in $T$ , all its descendants belong to $T$ .

You need to calculate the sum of $f(r, S)$ over all possible distinct combinations of vertices $r$ and subsets $S$ , where $|S| = k$ . Formally, compute the following: $$$$\sum_{r \in V} \sum_{S \subseteq V, |S| = k} f(r, S), $$ where $V$ is the set of vertices in $G$ .</p><p>Output the answer modulo $10^9 + 7$$$.

输入格式

The first line contains two integers $n$ and $k$ ( $3 \le n \le 2 \cdot 10^5$ , $1 \le k \le n$ ).

Each of the following $n - 1$ lines contains two integers $x$ and $y$ ( $1 \le x, y \le n$ ), denoting an edge between vertex $x$ and $y$ .

It is guaranteed that the given edges form a tree.

输出格式

Print the answer modulo $10^9 + 7$ .

输入输出样例

输入 #1
3 2
1 2
1 3
输出 #1
25
输入 #2
7 2
1 2
2 3
2 4
1 5
4 6
4 7
输出 #2
849
C++ 编辑器
输入
输出