hdu4405[Aeroplane chess] 有点懂了期望概率DP
2017-10-30 21:26
477 查看
f ( i)表示走到i的期望
f ( i ) = f ( i+j ) * ( 1 / 6 )
f ( i ) = nxt [i]
f ( i ) = f ( i+j ) * ( 1 / 6 )
f ( i ) = nxt [i]
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 1e5 + 10 ; int nxt ; double f ; int main () { int n , m ; while ( scanf ( "%d%d" , & n , & m ) != EOF && ( n != 0 || m != 0 ) ) { memset ( f , 0 , sizeof f ) ; memset ( nxt , 0 , sizeof nxt ) ; for ( int i = 1 ; i <= m ; ++ i ) { int x , y ; scanf ( "%d%d" , & x , & y ) ; nxt [x] = y ; } for ( int i = n-1 ; i >= 0 ; -- i ){ if ( nxt [i] ) { f [i] = f [ nxt [i] ] ; continue ; } for ( int j = 6 ; j >= 1 ; -- j ) f [i] += ( f [i+j] ) * ( 1.0 / 6 ) ; f [i] += 1 ; } printf ( "%.4lf\n" , f [0] ) ; } return 0 ; }
相关文章推荐
- hdu4405 Aeroplane chess【概率DP+期望问题】
- HDU4405:Aeroplane chess(概率dp & 期望)
- HDU4405-Aeroplane chess(概率DP求期望)
- 【期望DP】HDU4405 Aeroplane chess
- HDU 4405 Aeroplane chess (概率DP求期望)
- hdu4405 Aeroplane chess 【期望dp】
- HDU-4405 Aeroplane chess(概率DP求期望)
- HDU 4405 Aeroplane chess (概率DP求期望)
- hdu 4405 Aeroplane chess【概率DP求期望】
- 【HDU4405】【Aeroplane chess】【概率dp】
- [hdu 4405] Aeroplane chess [概率DP & 期望]
- HDU 4405 - Aeroplane chess (概率DP 求期望)
- hdu4405--Aeroplane chess(概率dp第七弹:飞行棋游戏--2012年网络赛)
- hdu 4405 Aeroplane chess(简单概率dp 求期望)
- 简单概率dp(期望)-hdu-4405-Aeroplane chess
- hdu 4405 Aeroplane chess (概率DP+求期望)
- hdu4405--Aeroplane chess(概率dp第七弹:飞行棋游戏--2012年网络赛)
- HDU4405--Aeroplane chess--概率DP
- HDU 4405 Aeroplane chess (概率DP & 期望)
- HDU 4403(Aeroplane chess ,求期望,概率DP)