How to count the number of pair of paths in a rooted tree whose sum=k ?
Difference between en1 and en2, changed 1 character(s)
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 : &mdash; ↵

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 so
me ideas on how to solve both of these problems ?  

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English codemode 2019-06-29 15:32:23 1 Tiny change: 'n I get soe ideas on' -> 'n I get some ideas on'
en1 English codemode 2019-06-29 15:31:04 577 Initial revision (published)