# HDU 4405 Aeroplane chess(概率DP入门)

#include<cstdio>
#include<algorithm>
#include<iostream>

using namespace std;
const int maxn = 100050;

double dp[maxn];
int mark[maxn];
int n,m;

void init(){
dp[0] = 0;
fill(mark,mark+maxn,-1);
fill(dp,dp+maxn,0);
}

int main(){
while(~scanf("%d%d",&n,&m)){
if(n + m  == 0) break;
init();
int a,b;
while(m--){
scanf("%d%d",&a,&b);
mark[a] = b;
}
for(int i=n-1;i>=0;i--){
if(mark[i] != -1) dp[i] = dp[mark[i]];
else{
double tmp = 0;
for(int j=1;j<=6;j++) tmp += dp[i+j];
dp[i] = tmp / 6 + 1;
}
}

printf("%.4f\n",dp[0]);
}
return 0;
}



#### HDU 4405 Aeroplane chess (概率dp)

2015-07-16 09:30:41

#### HDU - 4405 Aeroplane chess(概率dp)

2014-11-01 12:08:51

#### HDU 4405 Aeroplane chess 概率DP

2014-11-30 19:24:06

#### hdu 4405 Aeroplane chess （概率dp）

2013-10-23 23:01:42

#### HDU 4405 Aeroplane chess (概率DP)

2014-11-02 14:46:58

#### HDU 4405 Aeroplane chess (概率dp)

2014-04-02 18:08:30

#### hdu 4405 Aeroplane chess （概率DP）

2014-09-28 17:10:36

#### hdu 4405 Aeroplane chess（概率dp）

2014-07-14 21:56:55

#### hdu 4405 Aeroplane chess (概率dp)

2014-10-08 21:00:33

#### hdu 4405 Aeroplane chess 概率dp

2014-09-26 18:23:20