ADACITRS - Ada and Lemon 2
As you might already know, Ada the Ladybug is a farmer. She grows a big lemon tree. She wants to pick exactly one lemon (which grows on every leaf of the tree). She is wondering how many distinct trees will remain after harvesting exactly one lemon. Tree is different if they are distinct for each permutation of node labels.
Input
The first and only line will contain 25 ≤ N ≤ 3*105.
The next N-1 lines will contain two integers 0 ≤ a, b < N, a ≠ b, the edges of tree.
Output
For each test-case output the number of distinct trees after harvesting exactly one lemon.
Example Input
25 18 7 16 18 15 18 8 7 1 8 13 15 22 8 14 18 3 18 23 7 10 8 20 1 21 14 19 3 6 3 9 6 11 7 5 15 17 16 12 22 4 10 24 17 0 8 2 19
Example Output
7
Example Input
25 6 17 2 6 1 2 13 6 7 6 3 17 16 17 12 7 21 2 0 3 9 12 20 6 8 13 22 2 14 21 19 21 18 21 11 6 10 13 24 19 4 16 5 1 23 10 15 20
Example Output
10
Added by: | Morass |
Date: | 2017-10-26 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | http://www.spoj.com/problems/ADALEMON/ |