All submissions for this problem are available.
Given a tree, you need to count how many subtrees exist such that the length of the longest path in the subtree is at most K.
The first line contains the number of test cases T.
T test cases follow. For each test case, the first line contains N and K. The following N - 1 lines contain two integers ai and bi, indicating an edge between nodes ai and bi in the tree. There is a blank line after each test case.
Output T lines, one corresponding to each test case, containing the required answer.
Sample Input : 2 3 1 0 1 1 2 6 3 0 1 1 2 2 3 2 4 3 5
Sample Output : 5 23
Constraints : 1 <= T <= 2000 2 <= N <= 60 0 <= ai,bi < N 1 <= K <= N - 1
|Tags||medium, sept10, syco, tree|
|Time Limit:||0.133333 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, CPP17, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.