Codeforces C431 : DP Trees

I am not able to approach this ques. Also I didn’t understood the explanation given in the editorial. Kindly help.
Link : https://codeforces.com/problemset/problem/431/C

Hi,

Consider a tree having exactly k children. The weight of edge between parent and child is from 1 to k from left to right. You have to find the number of possible paths whose total edge weight is n and this path must also contain at least one edge having weight atleast d.
this is the question, i hope it is clear now.

I solved this problem by using dp. Consider two states: sum and flag, where sum is the sum upto current node and flag is the way to check whether the path which i have taken contain atleast one edge of weight greater than equal to d.

Now, try to solve this problem.

If you face difficulty you can refer to my code: