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 (GCC 5.4.1) (judge verdict: Accepted)

#include<stdio.h>
#include<stdlib.h>

typedef struct directedGraph{
  int *vertex;
  int *next;
  int *start;
  int v,e;
  int pointer;
} graph;

graph* newGraph(const int v,const int e){
  graph *g=(graph *)malloc(sizeof(graph));
  g->vertex=(int *)calloc(e,sizeof(int));
  g->next=(int *)calloc(e,sizeof(int));
  g->start=(int *)calloc(v,sizeof(int));
  for(int i=0;i<v;i++) g->start[i]=-1;
  g->v=v;
  g->e=e;
  g->pointer=0;
  return g;
}

void freeGraph(graph *g){
  free(g->vertex);
  free(g->next);
  free(g->start);
  free(g);
  return;
}

void addEdge(graph *g,const int from,const int to){
  const int p=g->pointer;
  g->vertex[p]=to;
  g->next[p]=g->start[from];
  g->start[from]=p;
  g->pointer++;
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  if(n==1){
    printf("0\n");
    return;
  }
  graph *g=newGraph(n,2*n);
  int i;
  for(i=0;i<n-1;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    addEdge(g,a,b);
    addEdge(g,b,a);
  }
  int *parent=(int *)calloc(n,sizeof(int));
  int *q=(int *)calloc(n,sizeof(int));
  int front=0;
  int last=0;
  q[last++]=0;
  while(last<n){
    int v=q[front++];
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(u==parent[v]) continue;
      parent[u]=v;
      q[last++]=u;
    }
  }
  double *dp1=(double *)calloc(n,sizeof(double));
  for(i=n-1;i>=0;i--){
    int v=q[i];
    double sum=0;
    int cnt=0;
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(u==parent[v]) continue;
      sum+=dp1[u];
      cnt++;
    }
    dp1[v]=cnt==0?0:(1+sum/cnt);
  }
  double *dp2=(double *)calloc(n,sizeof(double));
  double *ans=(double *)calloc(n,sizeof(double));
  for(i=0;i<n;i++){
    int v=q[i];
    double sum=dp2[v];
    int cnt=(i>0?1:0);
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(u==parent[v]) continue;
      sum+=dp1[u]+1;
      cnt++;
    }
    ans[v]=sum/cnt;
    for(int p=g->start[v];p!=-1;p=g->next[p]){
      int u=g->vertex[p];
      if(u==parent[v]) continue;
      dp2[u]=1;
      if(cnt>1) dp2[u]+=(sum-dp1[u]-1)/(cnt-1);
    }
  }
  for(i=0;i<n;i++) printf("%.9f\n",ans[i]);
}

int main(void){
  run();
  return 0;
}