report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Path with length k 2 - FlandreOJ: Flandre Online Judge

Path with length k 2

Time limit: 1000 ms
Memory limit: 256 MB
Given a tree of $n$ vertices. Count the number of simple paths with length $k$. ### Input - The first line contains an integer $n$. - The next $n - 1$ lines, each line contains 2 integers $u, v$, there is an edge between $u$ and $v$. ### Output - Print the number of paths with length $k$. ### Constraints - $1 \le k \le n \le 10^5$. - $1 \le u, v \le n$. ### Example Input: ``` 5 2 1 2 2 3 1 4 4 5 ``` Output: ``` 3 ```
Small-to-large
Distinct colors
Picking apples
Frequent color
Path with length k 2
LIS on tree
Topic
Tree
DSU
Rating 1800
Solution (0) Solution