QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#12022. A Tree

统计

Kele has a tree with $n$ vertices. The distance $dis(a,b)$ between two vertices $a$ and $b$ is defined as the minimum number of edges on the path between $a$ and $b$ in the tree.

Kele wants to choose $k$ edges from the tree to remove, and then add $k$ new edges such that the resulting graph is still a tree.

He wants to know the sum of $\sum_{i=1}^{n}\sum_{j=i+1}^{n}dis(i,j)$ over all valid choices (i.e., all ways to perform the operation such that the result is still a tree).

Since the answer may be very large, output the result modulo $998244353$.

Input

The first line contains two integers $n$ and $k$.

The next $n-1$ lines each contain two positive integers $(u_i, v_i)$ describing an edge of the tree.

Output

Output the answer modulo $998244353$.

Examples

Input 1

3 1
1 2
2 3

Output 1

16

Subtasks

For all test cases, it is guaranteed that $3\leq n\leq 10^5$ and $0\leq k\leq 1$. The input is guaranteed to be a tree.

Task 1 (9 pts): $n\leq 10$.

Task 2 (13 pts): $n\leq 100$.

Task 3 (11 pts): $n\leq 1000$.

Task 4 (10 pts): $k=0$.

Task 5 (17 pts): $u_i=i, v_i=i+1$.

Task 6 (40 pts): No additional constraints.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.