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 Java8 (OpenJDK 1.8.0) (judge verdict: Time Limit Exceeded)

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class Edge{
		int dst;
		int idx;
		public Edge(int d , int i) {
			dst = d;
			idx = i;
		}
	}
	static class Vertex{
		List<Edge> adj;
		public Vertex() {
			adj = new ArrayList<Edge>();
		}
		void add(int s , int d , int i){
			adj.add(new Edge(d, i));
		}
	}
	static double rec(int parent , int cur , double memo[] , List<Integer> ordering, int adj[][] , int idx[][]){
		ordering.add(cur);
		int P = 0;
		double S = 0.0;
		for(int i = 0 ; i < adj[cur].length ; ++i){
			int dst = adj[cur][i];
			if(dst == parent){
				continue;
			}
			int id = idx[cur][i];
			if(memo[id] < 0.0){
				double p = rec(cur , dst , memo , ordering , adj , idx) + 1.0;
				memo[id] = p;
			}
			S += memo[id];
			P = P + 1;
		}
		if(P == 0){
			return 0.0;
		}
		return S / P;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Vertex[] vs = new Vertex[N];
		for(int i = 0 ; i < N ; ++i){
			vs[i] = new Vertex();
		}
		for(int i = 0 ; i < N - 1 ; ++i){
			int u = sc.nextInt() - 1;
			int v = sc.nextInt() - 1;
			vs[u].add(u , v , i * 2);
			vs[v].add(v , u , i * 2 + 1);
		}
		int adj[][] = new int[N][];
		int idx[][] = new int[N][];
		for(int i = 0 ; i < N ; ++i){
			adj[i] = new int[vs[i].adj.size()];
			idx[i] = new int[vs[i].adj.size()];			
			for(int j = 0 ; j < vs[i].adj.size() ; ++j){
				adj[i][j] = vs[i].adj.get(j).dst;
				idx[i][j] = vs[i].adj.get(j).idx;
			}
		}
		List<Integer> ordering = new ArrayList<Integer>();
		double memo[] = new double[(N - 1) * 2];
		Arrays.fill(memo, -1);
		double ans[] = new double[N];
		rec(0, 0, memo, ordering, adj , idx);
		for(int cur : ordering){
			double S = 0.0;
			for(int i = 0 ; i < adj[cur].length ; ++i){
				S += memo[idx[cur][i]];
			}
			int size = vs[cur].adj.size();
			ans[cur] = S / size;
			for(int i = 0 ; i < adj[cur].length ; ++i){
				int id = idx[cur][i];
				int redge = id % 2 == 0 ? id + 1 : id - 1;
				if(size == 1){
					memo[redge] = 1.0;
				}else{
					double v = S - memo[id];
					memo[redge] = 1.0 + v / (size - 1);
				}
			}
		}
		for(double v : ans){
			System.out.println(v);
		}
	}
}