Блог пользователя codemode

Автор codemode, история, 5 лет назад, По-английски

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 ?

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится