// Hydro submission #672b21eda059678966637204@1730879981852
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-9;
int n, w[N], cnt[N], ans[N];
vector<int> g[N];
priority_queue<pair<double, int> > hep[N];
void dfs(int u){
cnt[u] = 1;
for(int v : g[u]){
dfs(v);
hep[u].push(make_pair((double)(ans[v]) / cnt[v], v));}
while(!hep[u].empty()){
if(hep[u].top().first <= (double)(ans[u]) / cnt[u] - eps)
break;
int v = hep[u].top().second; hep[u].pop();
cnt[u] += cnt[v], ans[u] += ans[v];
if(hep[u].size() < hep[v].size()) swap(hep[u], hep[v]);
while(!hep[v].empty()) hep[u].push(hep[v].top()), hep[v].pop();
}
return ;
}
signed main(){
cin >> n;
for(int i = 2, p; i <= n; i++)
cin >> p, g[p].push_back(i);
for(int i = 1; i <= n; i++) cin >> ans[i];
dfs(1);
for(int i = 1; i <= n; i++)
printf("%.10Lf\n", (double)(ans[i]) / cnt[i]);
return 0;
}