【HDU4405】Aeroplane chess
来源:互联网 发布:windows10装mac系统 编辑:程序博客网 时间:2024/05/29 19:18
题目链接:传送门
题解:
求期望从后往前递推
很容易得到
实际上把
如果点i可以飞向点j,直接
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=100010;int n,m;double f[N];int fly[N];int main(){ while(~scanf("%d%d",&n,&m)&&(n||m)) { memset(fly,0,sizeof(fly)); for(int i=1,u,v;i<=m;i++) { scanf("%d%d",&u,&v); fly[u]=v; } f[n]=0; for(int i=n-1;i>=0;i--) { if(fly[i]) f[i]=f[fly[i]]; else { f[i]=1; for(int j=1;j<=6;j++) f[i]+=(f[min(i+j,n)])/6; } } printf("%.4f\n",f[0]); } return 0;}
阅读全文
0 0
- HDU4405 Aeroplane chess
- hdu4405 Aeroplane chess 期望
- hdu4405 Aeroplane chess
- HDU4405 Aeroplane chess
- HDU4405-Aeroplane chess
- Hdu4405 Aeroplane chess 数论
- 【HDU4405】Aeroplane chess
- hdu4405 Aeroplane chess (概率dp)
- HDU4405--Aeroplane chess--概率DP
- hdu4405——Aeroplane chess
- 【HDU4405】【Aeroplane chess】【概率dp】
- hdu4405 Aeroplane chess 【期望dp】
- 【期望DP】HDU4405 Aeroplane chess
- hdu4405 Aeroplane chess---金华网络赛 期望
- hdu4405--Aeroplane chess+概率期望dp
- hdu4405 Aeroplane chess(期望dp)
- HDU4405 Aeroplane chess (概率DP求期望)
- hdu4405 Aeroplane chess【概率DP+期望问题】
- python 项目结构
- 牛客网编程基础9-11
- 订单分库分表实践总结
- dubbo源码深度解读一之common模块
- 生产者和消费者
- 【HDU4405】Aeroplane chess
- Redis--(linux安装redis3.2.9--教程)
- Android开发之蓝牙(一)——基于SPP协议蓝牙模块通信
- php扩展研究之一(实现a+b)
- Android与web后台进行数据交互的三种方式
- 数据结构之顺序栈的一些基本操作
- 【转】数据库索引的实现原理
- CountDownLatch
- Mongodb从0到1系列八: 备份与恢复