hdu4405 Aeroplane chess
Aeroplane chess
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1597 Accepted Submission(s): 1088
There are also M flight lines on the chess map. The i-th flight line can help Hzz fly from grid Xi to Yi (0<Xi<Yi<=N) without throwing the dice. If there is another flight line from Yi, Hzz can take the flight line continuously. It is granted that there is no two or more flight lines start from the same grid.
Please help Hzz calculate the expected dice throwing times to finish the game.
Each test case contains several lines.
The first line contains two integers N(1≤N≤100000) and M(0≤M≤1000).
Then M lines follow, each line contains two integers Xi,Yi(1≤Xi<Yi≤N).
The input end with N=0, M=0.
8 3
2 4
4 5
7 8
0 0
2.3441
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #define M(a,b) memset(a,b,sizeof(a))
- using namespace std;
- int n,m;
- int mp[];
- double dp[];
- int main()
- {
- while(scanf("%d%d",&n,&m)==&&(n||m))
- {
- int a,b;
- M(mp,);
- M(dp,);
- for(int i = ;i<m;i++)
- {
- scanf("%d%d",&a,&b);
- mp[a] = b;
- }
- for(int i = n-;i>=;i--)
- {
- if(mp[i]!=) dp[i] = dp[mp[i]];
- else
- {
- for(int j = ;j<=;j++)
- dp[i] += dp[i+j]/;
- dp[i] += ;
- }
- }
- printf("%.4f\n",dp[]);
- }
- return ;
- }
hdu4405 Aeroplane chess的更多相关文章
- HDU-4405 Aeroplane chess
http://acm.hdu.edu.cn/showproblem.php?pid=4405 看了一下这个博客http://kicd.blog.163.com/blog/static/12696191 ...
- HDU-4405 Aeroplane chess(概率DP求期望)
题目大意:一个跳棋游戏,每置一次骰子前进相应的步数.但是有的点可以不用置骰子直接前进,求置骰子次数的平均值. 题目分析:状态很容易定义:dp(i)表示在第 i 个点出发需要置骰子的次数平均值.则状态转 ...
- 2018.09.01 hdu4405 Aeroplane chess (期望dp)
传送门 期望dp简单题啊. 不过感觉题意不太对. 手过了一遍样例发现如果有捷径必须走. 这样的话就简单了啊. 设f[i]" role="presentation" sty ...
- HDU4405 Aeroplane chess 飞行棋 期望dp 简单
http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:问从起点到终点需要步数的期望,1/6的概率走1.2.3.4.5.6步.有的点a有路可以直接到b, ...
- [hdu4405]Aeroplane chess(概率dp)
题意:某人掷骰子,数轴上前进相应的步数,会有瞬移的情况,求从0到N所需要的期望投掷次数. 解题关键:期望dp的套路解法,一个状态可以转化为6个状态,则该状态的期望,可以由6个状态转化而来.再加上两个状 ...
- HDU4405 Aeroplane chess(期望dp)
题意 抄袭自https://www.cnblogs.com/Paul-Guderian/p/7624039.html 正在玩飞行棋.输入n,m表示飞行棋有n个格子,有m个飞行点,然后输入m对u,v表示 ...
- HDU4405 Aeroplane chess (概率DP,转移)
http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:在一个1×n的格子上掷色子,从0点出发,掷了多少前进几步,同时有些格点直接相连,即若a,b相连,当落 ...
- 【HDU4405】Aeroplane chess [期望DP]
Aeroplane chess Time Limit: 1 Sec Memory Limit: 32 MB[Submit][Stataus][Discuss] Description Hzz lov ...
- 刷题总结——Aeroplane chess(hdu4405)
题目: Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids labele ...
随机推荐
- VS2013无法启动 IIS Express Web解决办法
开发环境:windows8.1+VS2013 使用VS2013有一段时间了,因前期都是编写C/S程序,没有使用到B/S调试器.前几日,创建了一个MVC项目,突然发现VS2013无法调试,报了这样的错. ...
- kettle中全局变量的设置
设置全局变量. 找到.properties文件: 在文件中设置值: 在kettle中新建一个job(不用做任何设置): 转换中获取便元的设置: 重启kettle的执行结果:
- iOS网络编程
今天的重点是UIWebView.NSURLSession.JSon. 网络编程联网准备:1.在Info.plist中添加AppTransportSecurity类型Dictionary:2.在AppT ...
- python sokct 包详解
1. getaddrinfo简介getaddrinfo可解析得到IPv6地址,而gethostbyname仅能得到IPv4地址.getaddrinfo在Python的socket包中,以下为pytho ...
- dubbox 的各种管理和监管
dubbo官方自带了dubbo-admin及dubbo-simple/dubbo-monitor-simple二个子项目用于服务治理及服务监控. 一.dubbo-admin的部署 这个比较简单,编译打 ...
- [LeetCode] Strobogrammatic Number III 对称数之三
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
- [LeetCode] Remove Nth Node From End of List 移除链表倒数第N个节点
Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...
- Ajax状态值及状态码
1- AJAX状态值与状态码区别AJAX状态值是指,运行AJAX所经历过的几种状态,无论访问是否成功都将响应的步骤,可以理解成为AJAX运行步骤.如:正在发送,正在响应等,由AJAX对象与服务器交互时 ...
- 自建Ceph存储与 AWS、阿里云、腾讯云的成本对比
本文单从存储成本角度对比了自建Ceph存储和业界公有云存储的硬件成本,不包括IDC带宽成本. 统计Ceph集群的用到的主要设备为: OSD.MON.RGW服务器 .TOR交换机. 机架. 下表解释: ...
- mybatis 调用存储过程
<select id="selectGenCodeBySql" parameterType="hashmap" statementType="C ...