Tree Paths
시간 제한7초메모리 제한512 MB
트리에서 정점 번호가 연속 구간 a..b를 이루는 경로의 개수를 센다.
문제
There is a tree of vertices numbered to . A path is a sequence of distinct vertices such that , is an edge for all , and .
Count the number of paths such that the vertices form a contiguous range, or more formally, the set for some integers .
입력
The first line contains an integer (). The next lines contain the edges of the tree. The -th of these lines contains two space-separated integers and () denoting that is an edge. It is guaranteed that the given graph is a tree.
출력
On a single line output the desired number of paths.
힌트
The paths are , , , , and .