func_code_string: #include <bits/stdc++.h>   using namespace std;   int p, n;   vector<int> gra[100010];   double dp[100010], sz[100010];   void dfs(int u) {     sz[u] = 1;     int m = gra[u].size();     for (int i = 0; i <= m - 1; i++) {       dfs(gra[u][i]);       sz[u] += sz[gra[u][i]];     }   }   void solve(int u) {     int m = gra[u].size();     for (int i = 0; i <= m - 1; i++) {       dp[gra[u][i]] = dp[u] + 1 + (sz[u] - sz[gra[u][i]] - 1) / 2.0;       solve(gra[u][i]);     }   }   int main() {     dp[1] = 1;     scanf( %d , &n);     for (int i = 2; i <= n; i++) {       scanf( %d , &p);       gra[p].push_back(i);     }     dfs(1);     solve(1);     for (int i = 1; i <= n; i++) printf( %.6f  , dp[i]);     return 0;   }   