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 C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using vt=System.ValueTuple<int,int>;
using nint=System.Double;
static class Program{
	const int mod=(int)1e9+7;
	static List<vt>[] li;
	static bool[] b;
	static int[] pa;
	static nint[] dp;
	static nint[][] dpl,dpr;
	const int ie=0;
	static int ro;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=s[0],m=n-1;
		li=new List<vt>[n+1];
		b=new bool[n+1];
		dp=new nint[n+1];
		dpl=new nint[n+1][];
		dpr=new nint[n+1][];
		pa=new int[n+1];
		for(int i=1;i<=n;i++){
			li[i]=new List<vt>();
			li[i].Add((-1,-1));
		}
		for(int i=0;i<m;i++){
			var e=sc.Ia;
			li[e[0]].Add((e[1],1));
			li[e[1]].Add((e[0],1));
		}
		ro=1;
		for(int i = 1;i<=n;i++) {if(li[i].Count==2){ro=i;break;}}
		Fu1(ro,0);
		Fu2(ro,ie);
		StringBuilder sb=new StringBuilder();
		for(int i = 1;i<=n;i++) {sb.Append(dp[i]+"\n");}
		Console.Write(sb);
	}
	static void Fu2(int a,nint g){
		dp[a]=Fop(dpl[a][li[a].Count-1],g)/(li[a].Count-1);
		for(int i=1;i<li[a].Count;i++){
			if(li[a][i].Item1!=pa[a]){
				Fu2(li[a][i].Item1,Fop(Fop(dpl[a][i-1],dpr[a][i+1]),g)/(li[a].Count-(a==ro?1:2))+li[a][i].Item2);
			}
		}
	}
	static void Fu1(int a,int o){
		b[a]=true;
		pa[a]=o;
		dpl[a]=new nint[li[a].Count];
		dpr[a]=new nint[li[a].Count+1];
		dpl[a][0]=dpr[a][li[a].Count]=ie;
		for(int i=1;i<li[a].Count;i++){
			if(!b[li[a][i].Item1]){
				Fu1(li[a][i].Item1,a);
				dpl[a][i]=dpr[a][i]=dp[li[a][i].Item1]+li[a][i].Item2;
			}
			else{
				dpl[a][i]=dpr[a][i]=ie;
			}
			dpl[a][i]=Fop(dpl[a][i],dpl[a][i-1]);
		}
		for(int i = li[a].Count-1;i>=0;i--) {
			dpr[a][i]=Fop(dpr[a][i],dpr[a][i+1]);
		}
		dp[a]=dpl[a][li[a].Count-1];
		if(li[a].Count>2){dp[a]/=li[a].Count-(o==0?1:2);}
	}
	static nint Fop(nint a,nint b){
		return a+b;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}