Cities
시간 제한: 2000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — katt1BOJ 21334
문제
In a far away kingdom, there are cities numbered between and . The cities are connected by two-way roads. Each road has the same length, and connects exactly two cities, such that there is a unique path between any pair of cities.
For any two cities and , denote by the number of roads of this unique path between cities and . Given an integer , for how many pairs of cities is ?
입력
The sample judge reads input in the following format:
- line :
N K - line :
F[0] F[1] .. F[N - 2] - line :
T[0] T[1] .. T[N - 2]
출력
The sample judge will write a single line with the return value of paths(N, K, F, T).
예제
예제 1
입력
5 2 0 0 0 3 1 2 4 4
출력
4
코드를 제출하려면 로그인하세요.