hdu 4405 Aeroplane chess (概率)
来源:互联网 发布:淘宝助理怎么批量上传 编辑:程序博客网 时间:2024/05/22 20:55
e[i]表示走到i时,距离走到n还需扔骰子的次数的期望,如果没有可以直接飞行的点的话,递推公式就是e[i]=(e[i+1]+e[i+2]+e[i+3]+e[i+4]+e[i+5]+e[i+6])/6 + 1 ,有可以直接飞行的点就做一下变换就好了。
#include <iostream>#include<cstdio>#include<cstring>#define N 100020using namespace std;double e[N];int next[N];int main(){ int n,m,i,a,b,j; while(~scanf("%d%d",&n,&m)){ if(!n && !m) break; memset(next,0,sizeof(next)); for(i=0;i<m;i++){ scanf("%d%d",&a,&b); next[a]=b; } for(i=0;i<=n+6;i++) e[i]=0.0; for(i=n-1;i>=0;i--){ for(j=1;j<=6;j++){ int tmp=i+j; while(next[tmp]){ tmp=next[tmp]; } e[i]+=e[tmp]/6; } e[i]++; } printf("%.4lf\n",e[0]); } return 0;}
0 0
- hdu 4405 Aeroplane chess (概率)
- hdu 4405 Aeroplane chess 概率dp
- hdu 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess (概率dp)
- hdu 4405 Aeroplane chess(概率dp1)
- 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
- 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
- HDU - 4405 Aeroplane chess(概率dp)
- HDU 4405 Aeroplane chess (概率DP)
- HDU 4405 Aeroplane chess 概率DP
- 获取TextView中text行数
- python下安装美汤beautifulsoup包过程
- android手机屏幕适应
- [LeetCode]Flatten Binary Tree to Linked List
- 周末小记——一次不成功的组织同学聚会
- hdu 4405 Aeroplane chess (概率)
- Android:Layout_weight的深刻理解
- UVA - 10791 - Minimum Sum LCM (数论相关!)
- QTextEdit 读取一行 删除一行
- 出于安全原因 某些设置由系统管理员管理
- python最简单的计算器
- Android实例demo14之查看网络图片、根据编码格式查看html
- 【VNC】修改VNC分辨率大小
- Oanda外汇账户截至20141201净值403