All submissions for this problem are available.
Bob has just studied Trees and Graph Theory. Alice being an overachiever friend asked Bob to count the no of Pretty subtrees in an undirected tree. The tree is 1-indexed.
A subtree T' of tree T is called a Pretty Subtree if no of edges of the subtree T' connected to (T-T') is atmost k. Bob is amazed by this question.
Help Bob in solving the problem.
Two space separated integers N,K denoting the no of vertices and the value of K. Next N-1 lines contain two space separated integers a and b denoting an edge between a and b.
Print a single integer denoting the no of subtrees T' having atmost k connections to (T-T')
- 1 <= K <= N <=50
Input: 3 1 2 1 2 3 Output: 6
|Time Limit:||1 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, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions