hdu 4405 概率DP
2013-08-10 10:30
309 查看
直接上代码......
AC代码如下:
AC代码如下:
#include <iostream> #include <cstring> #include <cstdio> using namespace std; double dp[100001]; int nexts[100001]; int main(){ int N, M; while( cin >> N >> M && !( N == 0 && M == 0 ) ){ memset( dp, 0, sizeof( dp ) ); memset( nexts, 0, sizeof( nexts ) ); for( int i = 0; i < M; i++ ){ int temp1, temp2; cin >> temp1 >> temp2; nexts[temp1] = temp2; } for( int i = N - 1; i >= 0; i-- ){ if( nexts[i] != 0 ){ dp[i] = dp[nexts[i]]; }else{ for( int j = 1; j <= 6; j++ ){ int k = i + j >= N ? N : i + j; dp[i] += ( dp[k] + 1 ) / 6.0; } } } printf( "%.4lf\n", dp[0] ); } return 0; }
相关文章推荐
- HDU 4405 Aeroplane chess (概率DP & 期望)
- HDU 4405:Aeroplane chess(概率DP)
- HDU 4405 Aeroplane chess 概率DP
- HDU 4405 Aeroplane chess(概率dp)
- hdu 4405 飞行棋 概率dp
- HDU 4405 概率dp
- hdu 4405 Aeroplane chess(概率dp)
- HDU 4405(概率dp)
- HDU 4405 Aeroplane chess(概率DP)
- HDU 4405 Aeroplane chess(概率DP求期望)
- HDU 4405 Aeroplane chess(概率DP)
- hdu 4405 Aeroplane chess(概率dp)
- hdu 4405 Aeroplane chess (概率DP+求期望)
- 概率DP求期望入门,HDU 4405,POj 2096,HDU 3853
- HDU - 4405 Aeroplane chess [概率DP]
- hdu 4405 Aeroplane chess 概率dp
- HDU 4405 概率期望DP
- HDU 4405 概率期望DP
- [ACM] hdu 4405 Aeroplane chess (概率DP)
- 简单概率DP——hdu4405