当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6696:Dense Subgraph

题目描述
You have a tree on $n$ vertices, and each vertex has a weight $a_v$ and a degree at most $5$.

Let's call the density of a subset of vertices $S$ value $\frac{\sum_{v \in S} a_v}{|S|}$, and call the beauty of the tree with some vertices turned off the maximum value of the density of a subset of at least two turned on vertices with connected induced subgraph, or $0$ if no such subset exists.

Now you need to calculate the number of ways to choose such a set of turned off vertices among $2^n$ ways that the beauty of the tree is no larger than $x$, modulo $1\,000\,000\,007$.
输入解释
The input contains several test cases, and the first line contains a single integer $T~(1 \le T \le 30)$, the number of test cases.

The first line of each test case contains two integers $n~(2 \leq n \leq 35\,000)$ and $x~(0 \leq x \leq 35\,000)$, the number of vertices of a tree and the constraint on the beauty.

The next line contains $n$ integers $a_1, a_2, \ldots, a_n~(0 \leq a_i \leq 35\,000)$, the weights of the tree vertices.

Each of the next $n-1$ lines contains two integers $u$ and $v~(1 \leq u, v \leq n)$, describing an edge connecting vertices $u$ and $v$ in the tree.

It is guaranteed that each vertex of a tree has a degree at most $5$.
输出解释
For each test case, output a line containing a single integer, indicating the number of ways to choose such a set of turned off vertices among $2^n$ ways that the beauty of the tree is no larger than $x$, modulo $1\,000\,000\,007$.
输入样例
2
5 0
1 1 1 1 1
1 2
2 3
3 4
4 5
3 2
2 1 3
1 2
1 3
输出样例
13
6
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6696

最后修改于 2020-10-25T23:33:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/6000MS(Java/Others) 524288/524288K(Java/Others)