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

建议使用的浏览器:

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

6446:Tree and Permutation

题目描述
There are $N$ vertices connected by $N-1$ edges, each edge has its own length.
The set { $1, 2, 3, … , N$ } contains a total of $N!$ unique permutations, let’s say the $i$-th permutation is $P_i$ and $P_{i,j}$ is its $j$-th number.
For the $i$-th permutation, it can be a traverse sequence of the tree with $N$ vertices, which means we can go from the $P_{i,1}$-th vertex to the $P_{i,2}$-th vertex by the shortest path, then go to the $P_{i,3}$-th vertex ( also by the shortest path ) , and so on. Finally we’ll reach the $P_{i,N}$-th vertex, let’s define the total distance of this route as $D(P_i)$ , so please calculate the sum of $D(P_i)$ for all $N!$ permutations.
输入解释
There are 10 test cases at most.
The first line of each test case contains one integer $N$ ( $1 ≤ N ≤ 10^5$ ) .
For the next $N-1$ lines, each line contains three integer $X$, $Y$ and $L$, which means there is an edge between $X$-th vertex and $Y$-th of length $L$ ( $1 ≤ X, Y ≤ N, 1 ≤ L ≤ 10^9$ ) .
输出解释
For each test case, print the answer module $10^9+7$ in one line.
输入样例
3
1 2 1
2 3 1
3
1 2 1
1 3 2
输出样例
16
24
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6446

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

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)