Given an undirected tree, count how many paths that have at least length of k.

Правка en1, от EonHino, 2018-11-21 14:16:38

Statement

Given an undirected tree, count how many paths that have at least length of k.

Input

The first line is n (n <= 10 ^ 5) and k (k <= n) — the number of vertices and k as mentioned above. Next n — 1 line represents an edge.

5 2

1 2

2 3

2 4

4 5

Output

6

Explain

All paths that have at least length of k:

(1,3); (1,4); (1,5);

(2,5);

(3,4); (3,5);

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский EonHino 2018-11-21 19:09:25 111
en1 Английский EonHino 2018-11-21 14:16:38 511 Initial revision (published)