Random Isolation

AtCoder
IDarc165_e
Time2000ms
Memory256MB
Difficulty
There is a tree with $N$ vertices numbered $1$ to $N$. The $i$\-th edge connects vertices $A_i$ and $B_i$. Let us keep performing the following operation until each connected component of the graph has $K$ or fewer vertices. * From the $N$ vertices, choose one uniformly at random that belongs to a connected component with $K+1$ or more vertices. Delete all edges with the chosen vertex as an endpoint. Find the expected value of the number of times the operation is performed, modulo $998244353$. How to print an expected value modulo $\text{mod }{998244353}$It can be proved that the sought expected value is always a rational number. Additionally, under the constraints of this problem, it can also be proved that when that value is represented as an irreducible fraction $\frac{P}{Q}$, we have $Q \not \equiv 0 \pmod{998244353}$. Thus, there is a unique integer $R$ such that $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$. Report this $R$. ## Constraints * $1 \leq K < N \leq 100$ * $1 \leq A_i,B_i \leq N$ * The given graph is a tree. * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $K$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_{N-1}$ $B_{N-1}$ [samples]
Samples
Input #1
4 2
1 2
2 3
2 4
Output #1
249561090

For example, if the first operation chooses vertex $2$, it deletes all edges, after which each connected component has not more than two vertices, so we finish performing the operation. On the other hand, if the first operation chooses vertex $1$, there will still be a connected component with vertices $2$, $3$, and $4$, so we perform the second operation.
The expected value of the number of operations is $\frac{7}{4}$.
Input #2
20 10
16 8
6 2
18 3
3 12
5 1
13 9
13 19
3 11
5 13
17 6
8 14
1 16
16 20
11 15
3 10
15 4
5 18
1 7
1 17
Output #2
181196154
API Response (JSON)
{
  "problem": {
    "name": "Random Isolation",
    "description": {
      "content": "There is a tree with $N$ vertices numbered $1$ to $N$. The $i$\\-th edge connects vertices $A_i$ and $B_i$. Let us keep performing the following operation until each connected component of the graph ha",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc165_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There is a tree with $N$ vertices numbered $1$ to $N$. The $i$\\-th edge connects vertices $A_i$ and $B_i$.\nLet us keep performing the following operation until each connected component of the graph ha...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments