I was trying to solve the problem k-trees,

Actual Problem Link :- https://codeforces.com/problemset/problem/431/C

and was stuck to find how given test cases are giving answer , if anyone could help me with it! That would be really great.

Infinitely Rooted Tree means that the Tree has infinite number of node with a designated root.

As far as the explanation of the test cases:

1.) In the 1st test-case ( n=3,k=3,d=2)

Ans:- 3 ( [1,2], [2,1], [3] )

2.) In the 2nd test-case (n=3,k=3,d=3)

Ans:- 1 ( [3] )

As far as solution is considered. Question is same as finding Number of different ways to reach a score of N with possible length of each step should be less than or equal to k with at least 1 step length should be greater than or equal to d.

1 Like