#include
using namespace std;
struct edge { int t; edge *next; };
const int maxn = 100009; const int maxe = 600009; const int maxst = 800009;
int n, m, vis[maxn], dfn[maxn], low[maxn], tscc, fs[maxn], ssz[maxn], ind[maxn]; edge ebuf_arr[maxe], *ebuf(ebuf_arr), *head[maxn], *hg[maxn];
inline void addEdge(edge** head, int u, int v) { ebuf-> t = v; ebuf-> next = head[u]; head[u] = ebuf ++; }
void tarjanDFS(int po) { static int stc[maxst], stv[maxn], stt[maxn], fr[maxn], d[maxn]; int tsc(1), tsv(0), tst(0), dfi(0); d[stc[tsc] = po] = 1; vis[po] = 1; while (tsc) { int p(stc[tsc –]); if (dfn[p]) continue; for (; tsv && d[p] <= d[stv[tsv]]; – tsv) { low[fr[stv[tsv]]] = min(low[fr[stv[tsv]]], low[stv[tsv]]); if (low[stv[tsv]] == dfn[stv[tsv]]) { ssz[++ tscc] = 0; do { vis[stt[tst]] = 2; ++ ssz[fs[stt[tst]] = tscc]; } while (stt[tst –] != stv[tsv]); } } dfn[p] = low[p] = ++ dfi; stv[++ tsv] = stt[++ tst] = p; for (edge* e = head[p]; e; e = e-> next) if (!dfn[e-> t]) { d[e-> t] = d[p] + 1; fr[e-> t] = p; vis[e-> t] = 1; stc[++ tsc] = e-> t; } else if (vis[e-> t] == 1) low[p] = min(low[p], dfn[e-> t]); } for (; tsv; – tsv) { low[fr[stv[tsv]]] = min(low[fr[stv[tsv]]], low[stv[tsv]]); if (low[stv[tsv]] == dfn[stv[tsv]]) { ssz[++ tscc] = 0; do { vis[stt[tst]] = 2; ++ ssz[fs[stt[tst]] = tscc]; } while (stt[tst –] != stv[tsv]); } } }
bool checkSingle() { for (int i = 1; i <= tscc; ++ i) if (!ind[i] && ssz[i] == 1) { bool x(1); for (edge* e = hg[i]; e && x; e = e-> next) if (ind[e-> t] == 1) x = 0; if (x) return 1; } return 0; }
int main() { scanf("%d%d", &n, &m); memset(head, 0, sizeof(head)); for (int i = 0; i < m; ++ i) { int u, v; scanf("%d%d", &u, &v); addEdge(head, u, v); } memset(vis, 0, sizeof(vis)); tscc = 0; memset(dfn, 0, sizeof(dfn)); for (int i = 1; i <= n; ++ i) if (!vis[i]) tarjanDFS(i); int ans(0); memset(ind, 0, sizeof(ind)); memset(hg, 0, sizeof(hg)); for (int i = 1; i <= n; ++ i) for (edge* e = head[i]; e; e = e-> next) if (fs[i] != fs[e-> t]) { ++ ind[fs[e-> t]]; addEdge(hg, fs[i], fs[e-> t]); } for (int i = 1; i <= tscc; ++ i) if (!ind[i]) ++ ans; if (checkSingle()) – ans; printf("%.6lf", (double)(n - ans) / n); }