#include <cstdio>
#include <cstring>
const int maxn = 1E5 + 10;
double e[maxn];
int line[maxn], n, m, a, b;
int main(int argc, char const *argv[])
{
while (~scanf("%d%d", &n, &m) && n + m)
{
memset(e, 0, sizeof(e));
memset(line, -1, sizeof(line));
for (int i = 0; i < m; i++)
{
scanf("%d%d", &a, &b);
line[a] = b ;
}
for (int i = n - 1; i >= 0; i--)
if (line[i] != -1) e[i] = e[line[i]];
else
{
for (int j = 1; j <= 6; j++)
if (i + j <= n) e[i] += (1.0 / 6) * e[i + j];
else break;
e[i] += 1.0;
}
printf("%.4lf\n", e[0]);
}
return 0;
}
比如n=3,m=0
所列方程为e[0]=1/6e[1]+1/6e[2]+1/6e[3]+1
e[1]=1/6e[2]+1/6e[3]+1
e[2]=1/6e[3]+1
e[3]=0
直接从a跳到b,a的期望值也就等于b的期望值。(a<b)