Problem:
Max Score: $800$ Points

Problem Statement

There is an undirected connected graph with $N$ vertices and $N-1$ edges. The i-th edge connects u_i and v_i.

E869120 the coder moves in the graph as follows:

He move to adjacent vertex, but he can't a visit vertex two or more times.

He ends move when there is no way to move.

Otherwise, he moves randomly. (equal probability) If he has $p$ way to move this turn, he choose each vertex with $1/p$ probability.

Calculate the expected value of the number of turns, when E869120 starts from vertex i, for all i (1 ≤ i ≤ N).

Input

The input is given from standard input in the following format.

N
u_1 v_1
u_2 v_2
:
u_{N-1} v_{N-1}

Output

In i-th (1 ≤ i ≤ N) line, print the expected vaule of the number of turns E869120 moves.

The relative error or absolute error of output should be within 10^{-6}.

Constraints

$1 \le N \le 150,000$

The graph is connected.

Subtasks

Subtask 1 [ $190$ points ]

There is no vertex which degree is more than 2.

This means the graph looks like a list.

Subtask 2 [ $220$ points ]

1 ≤ N ≤ 1000.

Subtask 3 [ $390$ points ]

There are no additional constraints.

Sample Input 1

4
1 2
2 3
2 4

Sample Output 1

2.0
1.0
2.0
2.0

Sample Input 2

4
1 2
2 4
4 3

Solution in PyPy3 (2.4.0) (judge verdict: Time Limit Exceeded)

def main():
  n,*uv=map(int,open(0).read().split())
  identify=0
  edges = [[] for _ in range(n)]
  indexedges = [[] for _ in range(n)]
  for i in range(n-1):
    u,v=uv[i*2],uv[i*2+1]
    u-=1
    v-=1
    indexedges[v].append(len(edges[u]))
    indexedges[u].append(len(edges[v]))
    edges[u].append(v)
    edges[v].append(u)
  dp = [identify]*n
  subdp = [len(edges[i])*[identify] for i in range(n)]
  parents = [-1]*n
  order = [0]
  for node in order:
    for mode in edges[node]:
      if mode == parents[node]:
        continue
      order.append(mode)
      parents[mode] = node
  for i in range(n-1,0,-1):
    node = order[i]
    parent = parents[node]
    ans = identify
    indexparent = -1
    for j in range(len(edges[node])):
      mode = edges[node][j]
      if parent == mode:
        indexparent = j
        continue
      ans += subdp[node][j]
    if len(edges[node])==1:subdp[parent][indexedges[node][indexparent]]=1
    else:subdp[parent][indexedges[node][indexparent]]=1+ans/(len(edges[node])-1)
  for node in order:
    b = [identify]*len(edges[node])
    for i in range(len(edges[node])-1,0,-1):
      b[i-1] = b[i]+subdp[node][i]
    bb = identify
    for i in range(len(edges[node])):
      ans = bb+b[i]
      if len(edges[node])==1:subdp[edges[node][i]][indexedges[node][i]]=ans+1
      else:subdp[edges[node][i]][indexedges[node][i]]=ans/(len(edges[node])-1)+1
      bb += subdp[node][i]
    dp[node]=bb/len(edges[node])
  print(*dp)
if __name__ == "__main__":
  main()