Code:

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 100000 + 233;
const double perc = (1 / 6.0);
double f[maxn];
int vis[maxn];
int main()
{
int n,m;
while(1)
{
memset(vis, -1, sizeof(vis));
memset(f,0, sizeof(f));
scanf("%d%d",&n,&m);
if(!n) break;
for(int i = 1;i <= m; ++i)
{
int a,b;
scanf("%d%d",&a,&b);
vis[a] = b;
}
for(int i = n - 1;i >= 0;--i)
{
if(vis[i] != -1){ f[i] = f[vis[i]] ; continue; }
for(int j = 1;j <= 6; ++j) f[i] += (f[i + j] + 1) * perc;
}
printf("%.4lf\n",f[0]);
}
return 0;
}

  

Aeroplane chess HDU - 4405_数学期望_逆推的更多相关文章

  1. Codeforces Round #499 (Div. 2) C.FLY 数学推导_逆推

    本题应该是可以使用实数二分的,不过笔者一直未调出来,而且发现了一种更为优美的解法,那就是逆推. 首先,不难猜到在最优解中当飞船回到 111 号节点时油量一定为 000, 这就意味着减少的油量等于减少之 ...

  2. HDU 5984 数学期望

    对长为L的棒子随机取一点分割两部分,抛弃左边一部分,重复过程,直到长度小于d,问操作次数的期望. 区域赛的题,比较基础的概率论,我记得教材上有道很像的题,对1/len积分,$ln(L)-ln(d)+1 ...

  3. hdu 3853 LOOPS (概率dp 逆推求期望)

    题目链接 LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others)Tota ...

  4. HDU 4405 Aeroplane chess 期望dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Time Limit: 2000/1000 MS (Java/ ...

  5. HDU 4405:Aeroplane chess(概率DP入门)

    http://acm.split.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Problem Description   Hzz loves ...

  6. Aeroplane chess(HDU 4405)

    Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  7. 【整理】简单的数学期望和概率DP

    数学期望 P=Σ每一种状态*对应的概率. 因为不可能枚举完所有的状态,有时也不可能枚举完,比如抛硬币,有可能一直是正面,etc.在没有接触数学期望时看到数学期望的题可能会觉得很阔怕(因为我高中就是这么 ...

  8. ZOJ3551Bloodsucker (数学期望)

    In 0th day, there are n-1 people and 1 bloodsucker. Every day, two and only two of them meet. Nothin ...

  9. hdu 4405 Aeroplane chess(简单概率dp 求期望)

    Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

随机推荐

  1. sql语句学习(NOT EXISTS 和 NOT IN )

    NOT EXISTS SELECT a.*FROM t_user aWHERE a.id_card LIKE '%3203821995100%'AND NOT EXISTS ( SELECT id F ...

  2. 【ACM】hdu_zs1_1005_大明A+B _201307291603

    大明A+B Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)Total Submissi ...

  3. SCVMM-VMWARE ACE虚拟机管理工具

    SCVMM是微软的虚拟化管理工具 VMWARE ACE是另一套虚拟化的工具 这两套工具都是用来管理虚拟机的,可以直接将物理机虚拟化为虚拟机 企业一旦发展到了一定阶段,并然需要自己的服务器和虚拟化环境, ...

  4. MySQL备份 博客---MYSQLDBA 黄杉

    http://blog.csdn.net/mchdba/article/category/1598781

  5. PHP扩展开发-测验成功

    原文:http://kimi.it/496.html http://blog.csdn.net/u011957758/article/details/72234075 ---------------- ...

  6. 125条常见的java面试、笔试题大汇总

    1.抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解所有问题,而仅仅是选择当中的一部分,临时不用部分细节.抽象包含两个方面,一是过程抽象. ...

  7. Windows下Go语言 幽灵蛛的配置

    这里是环境变量 目录结构 在这其中,我主要需要观察src

  8. declare-styleable的使用

    declare-styleable:declare-styleable是给自定义控件添加自定义属性用的. 1.首先,先写attrs.xml 在res-vlaues文件夹下创建资源文件attrs.xml ...

  9. linux logo的格式【转】

    本文转载自:http://blog.csdn.net/xiayu98020214/article/details/7394100 =================================== ...

  10. [ZJOI 2010] 数字计数

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1833 [算法] 数位DP [代码] #include <algorithm&g ...