LA 4485 Crossing Rivers(概率,期望)
2014-01-15 13:52
302 查看
LA 4485 Crossing Rivers
从A到B的过程要坐船经过几条河 ,每条船的初始位置和行驶方向是随机等概率的 。求从A到B的期望时间?
分析:
假设:河宽L, 船速V , 初始位置X ,过河时间t .
则 E[ t ] =
![](https://img-blog.csdn.net/20140115135501375?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGdfY3N1/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
可见平均过河时间只与河宽和船速有关。
参考代码:
从A到B的过程要坐船经过几条河 ,每条船的初始位置和行驶方向是随机等概率的 。求从A到B的期望时间?
分析:
假设:河宽L, 船速V , 初始位置X ,过河时间t .
则 E[ t ] =
可见平均过河时间只与河宽和船速有关。
参考代码:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { int N , D ,cas = 1; while(scanf("%d%d" ,&N , &D) ,N+D){ double t = 0 , s = 0 , p , l ,v; for(int i=0;i<N;i++){ scanf("%lf%lf%lf" ,&p , &l ,&v); t += 2*l / v; s += l; } t += D - s; printf("Case %d: %.3f\n" ,cas++ , t); printf("\n"); } return 0; }
相关文章推荐
- SDUT 飞行棋 (概率DP & 期望)
- 概率与期望
- Hdu 5570 概率期望
- 1419: Red is good 概率与期望 DP
- 【概率与期望】[UVA11021]Tribles
- BZOJ3036[绿豆蛙的归宿] 期望概率DP
- hdu 4586 Play the Dice(概率期望题)
- hdu4405[Aeroplane chess] 有点懂了期望概率DP
- lightoj1104(数学概率与期望)
- Activation HDU - 4089 概率期望dp
- A1490. osu!(乔明达)|概率与期望|卡常|矩阵
- zoj3640(概率DP求期望)
- HDU 5159 Card(概率期望)
- 无聊做做数学题系列2 - 概率统计与数学期望
- bzoj 1419 Red is good - 动态规划 - 概率与期望
- hdu 5162(概率期望)
- 【专题总结】概率与期望(持续更新)
- Codeforces 28C Bath Queue - 动态规划 - 组合数学 - 概率与期望
- ZOJ3329-One Person Game(概率DP求数学期望)
- LightOJ 1038 Race to 1 again 期望+概率dp