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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
vector<int> G[202020];

double per[202020];

void dfs1(int v,int f = -1){
  int cnt = 0;
  for(int to : G[v]){
    if(to == f) continue;
    dfs1(to,v);
    cnt++;
    per[v] += per[to];
  }
  if(cnt != 0){
    per[v] /= cnt;
    per[v]++;
  }
}

double ans[202020];

void dfs2(int v,int f = -1,double f_per = 0){
  int cnt = G[v].size();
  double sum = 0;
  for(int to : G[v]){
    if(to == f){
      sum += f_per;
    }
    else{
      sum += per[to];
    }
  }
  cout << v << " " << f_per << " " << sum <<endl;
  ans[v] = sum / cnt + 1;

  for(int to : G[v]){
    if(to == f) continue;
    double t = sum - per[to];
    if(cnt > 1) t = t / (cnt - 1) + 1;
    dfs2(to,v,t);
  }
}

int main(){
  cin >> N;
  for(int i = 0;i < N - 1;i++){
    int u,v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs1(0);
  dfs2(0);
  cout << fixed << setprecision(10);
  for(int i = 0;i < N;i++){
    cout << ans[i] <<endl;
  }
}