http://acm.hdu.edu.cn/showproblem.php?pid=4405

题意:每次可以走1~6格,初始化在第0格,走到>=n的格子就结束。还有m个传送门,表示可以从X[i]格传送到Y[i]而不需要消耗次数,X[i]<Y[i]。n<=100000, m<=1000。

#include <cstdio>
#include <cstring>
using namespace std;
double d[100010];
int n, m, mp[100010], X[1005], Y[1005];
int main() {
while(scanf("%d%d", &n, &m), !(n==0&&m==0)) {
for(int i=0; i<m; ++i) scanf("%d%d", &X[i], &Y[i]);
for(int i=0; i<m; ++i) mp[X[i]]=Y[i];
for(int i=n-1; i>=0; --i) {
if(mp[i]) d[i]=d[mp[i]];
else {
d[i]=(d[i+1]+d[i+2]+d[i+3]+d[i+4]+d[i+5]+d[i+6])/6+1;
}
}
printf("%.4f\n", d[0]);
memset(d, 0, sizeof(double)*(n));
for(int i=0; i<m; ++i) mp[X[i]]=0;
}
return 0;
}

  

好裸的期望dp...由于转移都是互斥的,直接搞。。

由于正推不好判断多个Y[i]重合的情况,所以逆推..

【HDU】4405 Aeroplane chess的更多相关文章

  1. HDU 4405 Aeroplane chess 期望dp

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

  2. 【HDU】4888 Redraw Beautiful Drawings 网络流【推断解是否唯一】

    传送门:pid=4888">[HDU]4888 Redraw Beautiful Drawings 题目分析: 比赛的时候看出是个网络流,可是没有敲出来.各种反面样例推倒自己(究其原因 ...

  3. 【刷题】HDU 4405 Aeroplane chess

    Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled fr ...

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

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

  5. hdu 4405 Aeroplane chess (概率DP)

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

  6. hdu 4405 Aeroplane chess(概率+dp)

    Problem Description Hzz loves aeroplane chess very much. The chess map contains N+ grids labeled to ...

  7. [ACM] hdu 4405 Aeroplane chess (概率DP)

    Aeroplane chess Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 ...

  8. 【HDU】2191 多重背包问题

    原题目:悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 [算法]多重背包(有限背包) 动态规划 [题解]http://blog.csdn.net/acdreamers/article/detail ...

  9. 【HDU】6110 路径交(2017百度之星) 线段树+RMQ-LCA+树链的交

    [题目]2017"百度之星"程序设计大赛 - 初赛(A) [题意]给定n个点的带边权树,m条编号1~m的路径,Q次询问编号区间[L,R]所有链的交集的长度.n<=500000 ...

随机推荐

  1. C# 面试宝典

    1.简述 private. protected. public. internal 修饰符的访问权限. private  私有成员 只有类成员才能访问 protected  保护成员 只有该类及该类的 ...

  2. JSON C# Class Generator ---由json字符串生成C#实体类的工具(转)

    转载地址:http://www.cnblogs.com/finesite/archive/2011/07/31/2122984.html json作为互联网上轻量便捷的数据传输格式,越来越受到重视.但 ...

  3. Delphi管理多线程之线程局部存储:threadvar

    尽管多线程能够解决许多问题,但是同时它又给我们带来了很多的问题.其中主要的问题就是:对全局变量或句柄这样的全局资源如何访问?另外,当必须确保一个线程中的某些事件要在另一个线程中的其他时间之前(或之后) ...

  4. 安装oracle 12c RAC遇到的一些问题

    (1) 安装grid软件,停止在38%很长时间不动,日志显示正常   解决方法: 由于是虚拟机安装,设置的内存为600M,关闭虚拟机,把内存调成1GB,问题解决~在38%Linking RMAN Ut ...

  5. 使用.NET Framework的配置文件app.config

    在一般的项目中,为了使你的代码更加灵活,更方便调整,减少不必要的hard code,我们都在config中添加许多配置信息,一般可以选择.NET自带的配置文件形式app.config或者web项目中的 ...

  6. PowerDesigner生成sql及HTML格式数据库文档

    一.PowerDesigner生成sql问题 生成sql的方法是 Database -->Generate Database (Ctrl + G ) 但是提示 Could not load VB ...

  7. 攻城狮在路上(叁)Linux(零)--- 软件环境、参考书目等一览表

    1.参考书目:鸟哥的Linux私房菜. 2.环境: Cent_os.

  8. js 节点 document html css 表单节点操作

    js 节点 document html css 表单节点操作 节点操作:访问.属性.创建 (1)节点的访问:firstChild.lastChild.childNodes.parentChild(父子 ...

  9. Accelerating Matlab

    Matlab is a very useful programming environment, but it also has many inefficiencies. You might thin ...

  10. 2016 ACM/ICPC Asia Regional Dalian Online HDU 5877 Weak Pair treap + dfs序

    Weak Pair Problem Description   You are given a rooted tree of N nodes, labeled from 1 to N. To the  ...