题意

抄袭自https://www.cnblogs.com/Paul-Guderian/p/7624039.html

正在玩飞行棋。输入n,m表示飞行棋有n个格子,有m个飞行点,然后输入m对u,v表示u点可以直接飞向v点,即u为飞行点。如果格子不是飞行点,扔骰子(1~6等概率)前进。否则直接飞到目标点。每个格子是唯一的飞行起点,但不是唯一的飞行终点。问到达或越过终点的扔骰子期望数。

从0出发!!

Sol

比较zz的期望dp

设$f[i]$表示从$i$出发,到达$n$的期望步数

转移的时候讨论一下即可

/*

*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
//#define int long long
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
using namespace std;
const int MAXN = 1e5 + , INF = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, M, to[MAXN];
double f[MAXN];
int main() {
while(scanf("%d %d", &N, &M)) {
if((N == ) && (M == )) break;
memset(to, , sizeof(to));
memset(f, , sizeof(f));
for(int i = ; i <= M; i++) {
int x = read(), y = read();
to[x] = y;
}
for(int x = N - ; x >= ; x--) {
if(to[x]) f[x] = f[to[x]];
else {
for(int j = ; j <= ; j++) f[x] += f[x + j];
f[x] /= ; f[x]++;
}
}
printf("%.4lf\n", f[]);
}
return ;
}
/* */

HDU4405 Aeroplane chess(期望dp)的更多相关文章

  1. 【HDU4405】Aeroplane chess [期望DP]

    Aeroplane chess Time Limit: 1 Sec  Memory Limit: 32 MB[Submit][Stataus][Discuss] Description Hzz lov ...

  2. HDU 4405 Aeroplane chess 期望dp

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

  3. [hdu4405]Aeroplane chess(概率dp)

    题意:某人掷骰子,数轴上前进相应的步数,会有瞬移的情况,求从0到N所需要的期望投掷次数. 解题关键:期望dp的套路解法,一个状态可以转化为6个状态,则该状态的期望,可以由6个状态转化而来.再加上两个状 ...

  4. HDU4405 Aeroplane chess (概率DP,转移)

    http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:在一个1×n的格子上掷色子,从0点出发,掷了多少前进几步,同时有些格点直接相连,即若a,b相连,当落 ...

  5. 2018.09.01 hdu4405 Aeroplane chess (期望dp)

    传送门 期望dp简单题啊. 不过感觉题意不太对. 手过了一遍样例发现如果有捷径必须走. 这样的话就简单了啊. 设f[i]" role="presentation" sty ...

  6. HDU4405 Aeroplane chess 飞行棋 期望dp 简单

    http://acm.hdu.edu.cn/showproblem.php?pid=4405   题意:问从起点到终点需要步数的期望,1/6的概率走1.2.3.4.5.6步.有的点a有路可以直接到b, ...

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

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

  8. hdu4405 Aeroplane chess

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

  9. HDU-4405 Aeroplane chess

    http://acm.hdu.edu.cn/showproblem.php?pid=4405 看了一下这个博客http://kicd.blog.163.com/blog/static/12696191 ...

随机推荐

  1. Azure ARM (22) Azure Policy入门

    <Windows Azure Platform 系列文章目录> 我们知道,在Azure服务层级中,分为以下几个层次: 1.企业合同 2.订阅 3.资源组 4.资源 我们使用的Azure资源 ...

  2. POJ2274(后缀数组应用)

    Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 25272   Accepted: 10 ...

  3. Ubuntu 安装Guake

    一款代替终端的软件, 只需按F12就可以调出终端, 再按就消失, 附上Github链接. https://github.com/Guake/guake 一开始没安装上去, 后来成功, 现在用着还不错, ...

  4. 抓屏工具 faststone capture

    百度百科 http://baike.baidu.com/link?url=te51CfOKYIEmqT1jsyRwcB8Pnals5xQ8nUXk6trvBPGSJRBO5G7BEZL7cYQxmx8 ...

  5. JAVA NIO non-blocking模式实现高并发服务器

    JAVA NIO non-blocking模式实现高并发服务器 分类: JAVA NIO2014-04-14 11:12 1912人阅读 评论(0) 收藏 举报 目录(?)[+] Java自1.4以后 ...

  6. 1.18-1.21 Oozie Coordinator调度

    一.时区问题 1.修改系统时区 ## [root@hadoop-senior hadoop-2.5.0-cdh5.3.6]# rm -rf /etc/localtime [root@hadoop-se ...

  7. 1.13-1.14 Hive Action

    一.Hive Action 1.创建文件 [root@hadoop-senior oozie-apps]# pwd /opt/cdh-5.3.6/oozie-4.0.0-cdh5.3.6/oozie- ...

  8. 技术胖Flutter第三季-16Stack层叠布局

    16Stack层叠布局 在上面声明一个变量Stack里面包含两个元素,第一个 是CircleAvater第二个子对象是Container 效果 把文字房子啊中下的位置: 我们需要对齐属性 包含了x轴和 ...

  9. jQuery 设置图片 src 的2种方法

    // 方法1 $('#imgValidateCode').attr("src", data.CodeUrl); // 方法2 var self = $("#refresh ...

  10. C#利用WebService接口下载文件

    WebTest.RtTfSimDataInterface test = new WebTest.RtTfSimDataInterface(); //string strBasic = test.Get ...