structEdge { int to, next; } e[maxn * 2]; int c1, head[maxn]; inlinevoidadd_edge(int u, int v){ e[c1].to = v; e[c1].next = head[u]; head[u] = c1++; }
int dep[maxn]; double ans; voiddfs(int u, int fa){ ans += 1.0 / dep[u]; for (int i = head[u]; ~i; i = e[i].next) { int v = e[i].to; if (v == fa) continue; dep[v] = dep[u] + 1; dfs(v, u); } }
intmain(){ fill(head, head + maxn, -1); ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n; for (int i = 1; i < n; ++i) { int x, y; cin >> x >> y; add_edge(x, y); add_edge(y, x); } dep[1] = 1; dfs(1, 0); cout << fixed << setprecision(7) << ans << "\n"; return0; }