Divisible Trees
시간 제한5초메모리 제한2048 MB
트리 T가 주어졌을 때, T를 A의 k개 복사본이 k-1개의 간선으로 이어진 형태로 만들 수 있는 서로 다른 (비라벨) 트리 A의 개수를 센다.
문제
Let and be two undirected trees. We define the sum as the set of all undirected trees that can be obtained by connecting the trees and with a single edge between any node in and any node in .
Similarly, we define the product of a scalar and a tree as a set of trees which look like copies of connected by new edges. For example, is the set consisting of a single tree . The set is just . Now, is the set of trees each of which is copies of with additional edges connecting them into a single tree. And so on.
We say that a tree divides a tree if there exists a positive integer such that is included in the set . We observe that, similar to divisibility in the case of natural numbers, any tree is divisible by itself and the "unit" tree: the tree consisting of a single node.
Given a tree , the task is to count how many distinct trees divide it.
We say that two trees are distinct if vertices of one tree cannot be relabeled to obtain the other tree.
입력
The first line of the input contains a single integer (), the number of vertices in the tree.
Each of the next lines contains two distinct integers and (), the ends of an edge in the tree.
출력
Output a single integer, the number of distinct trees that divide .