func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /stack:16777216 )   using namespace std;   const int INF = 1000000000;   const int MAX = 1000006;   const int MAX2 = 207;   const int BASE = 1000000000;   const int CNT = 500;   const int MOD = 1000000007;   vector<int> g[MAX];   int sz[MAX];   double ans[MAX];   void dfs(int v, int p) {     sz[v] = 1;     for (int i = (0); i < (g[v].size()); ++i) {       int to = g[v][i];       if (to == p) {         continue;       }       dfs(to, v);       sz[v] += sz[to];     }   }   void dfs2(int v, int p) {     if (p == -1) {       ans[v] = 1;     } else {       int ps = sz[p] - 1;       int mysz = sz[v];       ans[v] = ans[p] + 1 + (ps - mysz) * 0.5;     }     for (int i = (0); i < (g[v].size()); ++i) {       int to = g[v][i];       if (to == p) {         continue;       }       dfs2(to, v);     }   }   int main() {     int n;     cin >> n;     for (int i = (1); i < (n); ++i) {       int v;       cin >> v;       --v;       g[v].push_back(i);       g[i].push_back(v);     }     dfs(0, -1);     dfs2(0, -1);     for (int i = (0); i < (n); ++i) printf( %.8lf  , ans[i]);     return 0;   }   