codemode's blog

By codemode, history, 19 months ago, In English

We are given a rooted tree with 'n' vertices, where , n<=10^5.

For the problem : Count the number of paths in a tree with sum=k .

I don't know its efficient solution.

And now the new problem is : —

Count the number of pair of paths in a rooted tree with sum=k.

Example, say the path(2-5) in a tree has sum=8, and another path (7-9) in the same tree has sum=9.

So the pair of paths:- {(2-5),(7-9)} has a sum=8+9=17.

Can I get some ideas on how to solve both of these problems ?

  • Vote: I like it
  • -2
  • Vote: I do not like it

19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by codemode (previous revision, new revision, compare).