#include <bits/stdc++.h>
using namespace std;
int entry[3005], low[3005], n, tme = 1, scc[3005], sp[3005], cycle, cnt;
vector<int> myvec[3005], ans;
map<pair<int, int>, bool> bridges;
double prob[3005], ret;
queue<int> q;
int dfs(int x, int p) {
  int i, j, k;
  low[x] = entry[x] = tme++;
  for (i = 0; i < myvec[x].size(); i++) {
    j = myvec[x][i];
    if (j == p) continue;
    if (entry[j] == 0) {
      k = dfs(j, x);
      if (k > entry[x]) {
        bridges[make_pair((min(j, x)), max(j, x))] = 1;
      }
      low[x] = min(low[x], k);
    } else {
      low[x] = min(low[x], entry[j]);
    }
  }
  return low[x];
}
void make_scc(int x, int c) {
  scc[x] = c;
  cnt++;
  int i, j, k;
  for (i = 0; i < myvec[x].size(); i++) {
    j = myvec[x][i];
    if (scc[j] != -1) continue;
    if (bridges[make_pair(min(j, x), max(j, x))]) continue;
    make_scc(j, c);
  }
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scc[i] = -1;
    scanf("%d %d", &j, &k);
    myvec[j].push_back(k);
    myvec[k].push_back(j);
  }
  dfs(1, 0);
  for (i = 0; i < n; i++) {
    if (scc[i] != -1) continue;
    cnt = 0;
    make_scc(i, i);
    cycle = max(cycle, cnt);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) sp[j] = 0;
    q.push(i);
    sp[i] = 1;
    while (!q.empty()) {
      k = q.front();
      q.pop();
      for (j = 0; j < myvec[k].size(); j++) {
        if (sp[myvec[k][j]]) continue;
        sp[myvec[k][j]] = sp[k] + 1;
        q.push(myvec[k][j]);
      }
    }
    for (j = 0; j < n; j++) {
      if (j == i || scc[i] != scc[j]) {
        prob[j] = (1 / (double)sp[j]);
      } else {
        double d = sp[j];
        prob[j] = 1 / d + ((d - 2) / (d * (cycle + 2 - d)));
      }
      ret += prob[j];
    }
  }
  printf("%.8lf\n", ret);
  return 0;
}
