Under construction

Still being built. Things may change

Cascade Centrality

Interview

Time limit1sMemory limit1024 MB

Summary
Given a tree, find the mean cascade centrality of its nodes, where each path adds the reciprocal of the product of degrees along it.
Level

Easy3 of 10

Topics
Tree, DFS, Math
Solved
No attempts yet

Problem

Given an undirected graph G=(V,E)G=(V,E), the cascade centrality of node ii in VV is defined as 1+∑j∈V∖{i}∑P∈Pij1χP,1 + \sum_{j \in V \setminus \{i\}} \sum_{P \in P_{ij}} \frac{1}{\chi_P}, where PijP_{ij} is the set of all simple paths from node ii to node jj. The degree sequence product χP\chi_P of a path is the product of the degrees of all nodes along the path, including the ending node but excluding the starting node.

Since GG is a tree, PijP_{ij} always contains exactly one path. Find the mean of the cascade centralities of the nodes in GG.

Input

The first line contains an integer NN (1≤N≤100)(1 \leq N \leq 100), the number of nodes in the tree. Each of the next N−1N-1 lines contains two space-separated integers uiu_i and viv_i (1≤ui,vi≤N)(1 \leq u_i, v_i \leq N), denoting an undirected edge between nodes uiu_i and viv_i. No edge connects a node to itself, and there is at most one edge between any pair of nodes. The given graph is connected and has no cycles.

Output

Print the mean of the cascade centralities of the nodes in the graph. Your answer is accepted if it differs from the judge answer by at most 10−610^{-6} in relative or absolute error.

Examples3

  1. Example 1

    Input
    1
    
    Expected output
    1.000000
    
  2. Example 2

    Input
    2
    1 2
    
    Expected output
    2.000000
    
  3. Example 3

    Input
    3
    1 3
    3 2
    
    Expected output
    2.333333