HDU4405 Areoplane chess(期望dp)
来源:互联网 发布:退休工资计算软件 编辑:程序博客网 时间:2024/05/29 08:47
Areoplane chess
传送门1
传送门2
Hzz loves aeroplane chess very much. The chess map contains
There are also M flight lines on the chess map. The i-th flight line can help Hzz fly from grid
Please help Hzz calculate the expected dice throwing times to finish the game.
Input
There are multiple test cases.
Each test case contains several lines.
The first line contains two integers
Then
The input end with
Output
For each test case in the input, you should output a line indicating the expected dice throwing times. Output should be rounded to 4 digits after decimal point.
Sample Input
2 0
8 3
2 4
4 5
7 8
0 0
Sample Output
1.1667
2.3441
题意
数轴上有
分析
期望dp.(期望dp一般逆推)
定义
1. 对于可以直接飞的点,
2. 不能飞的点,
CODE
#include<cstdio>#include<memory.h>#define N 100005#define FOR(i,a,b) for(int i=(a),i##_END_=(b);i<=i##_END_;i++)#define ROF(i,a,b) for(int i=(a),i##_END_=(b);i>=i##_END_;i--)double dp[N];int fly[N];int main() { int n,m; while(~scanf("%d%d",&n,&m)&&(n||m)) { memset(fly,-1,sizeof fly); FOR(i,1,m) { int a,b; scanf("%d%d",&a,&b); fly[a]=b; } memset(dp,0,sizeof dp); ROF(i,n-1,0) { if(fly[i]==-1) { FOR(j,i+1,i+6)dp[i]+=dp[j]/6.0; dp[i]++; } else dp[i]=dp[fly[i]]; } printf("%.4lf\n",dp[0]); } return 0;}
- HDU4405 Areoplane chess(期望dp)
- hdu4405 Aeroplane chess(期望dp)
- HDU4405:Aeroplane chess(概率dp & 期望)
- hdu4405 Aeroplane chess 【期望dp】
- 【期望DP】HDU4405 Aeroplane chess
- HDU4405-Aeroplane chess(概率DP求期望)
- hdu4405--Aeroplane chess+概率期望dp
- HDU4405 Aeroplane chess (概率DP求期望)
- hdu4405 Aeroplane chess【概率DP+期望问题】
- hdu4405 Aeroplane chess 期望
- hdu4405[Aeroplane chess] 有点懂了期望概率DP
- hdu4405(概率DP求期望)
- hdu4405(期望dp)
- hdu4405 Aeroplane chess (概率dp)
- HDU4405--Aeroplane chess--概率DP
- 【HDU4405】【Aeroplane chess】【概率dp】
- hdu4405 Aeroplane chess---金华网络赛 期望
- HDU4405(概率DP求期望)
- 解决IntelliJ IDEA 控制台输出乱码问题
- 世界物联网排行榜: 华为第一、思科第二,物联网发展趋势该如何看?
- Google Playtime 2017 隆重登场, 助力出海开发者获得成功!
- R----stringr包介绍学习
- 归并排序(分治算法)
- HDU4405 Areoplane chess(期望dp)
- Exp 导出含有blob字段的表
- activity的onCreate(Bundle saveInstanceState)中入参的概念和使用
- python函数-变量作用域
- 学习笔记TF052:卷积网络,神经网络发展,AlexNet的TensorFlow实现
- oracle各种trace清理
- Android Studio升级3.0遇到的小坑
- 【省选模拟试题】排水系统 dijkstra+最短路径树+优先队列维护(当然这个和dij的不是同一个)
- Spring 学习笔记(2)—— ApplicationContext 及 WebApplicationContext 的初始化