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;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, E[150000][2], deg[150000];
vi G[150000];
double dp[150001][2];

double f(int e, int s) {
    double &res = dp[e][s];
    if (res > -1)return res;
    int u = E[e][s];
    res = 0;
    if (sz(G[u]) == 1)return res;
    double p = 1.0 / (sz(G[u]) - 1);

    each(ne, G[u])if (ne != e) {
        res += f(ne, E[ne][0] == u);
    }
    res = res*p + 1.0;
    return res;
}

int main(){

    int isLine = 1;
    scanf("%d", &N);
    rep(i, N-1) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;
        deg[u]++;
        deg[v]++;
        E[i][0] = u;
        E[i][1] = v;
    }

    rep(i, N)if (deg[i] > 2)isLine = 0;
    if (isLine) {
        double ans = 0.5*(N - 1);
        rep(i, N)printf("%.10f\n", ans);
        exit(0);
    }
    rep(i, N - 1)rep(j, 2)G[E[i][j]].push_back(i);
    rep(i, N)rep(j, 2)dp[i][j] = -2;
    rep(i, N) {
        double ans = 0, p = -1;
        if (sz(G[i]))p = 1.0 / sz(G[i]);
        each(e, G[i]) {
            ans += f(e, E[e][0] == i);
        }
        if (sz(G[i]))ans = ans*p + 1;
        printf("%.10f\n", ans);
    }
}