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 ...
随机推荐
- [Penetration Testing Devil Training Camp Based on Metasploit] Learn & Practice
- Linux文本查看及处理.md
cat cat命令的用途是连接文件或标准输入并打印.这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用. 主要功能 一次显示整个文件:cat ...
- [LeetCode] Total Hamming Distance 全部汉明距离
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- 【C#】新建服务自动发送邮件
---windows服务,---自动发送邮件 邮件发送code #region 发送邮件函数 public void SendMailUseZj() { System.Net.Mail.MailMes ...
- System.Environment.CurrentDirectory和Application.StartupPath
System.Environment.CurrentDirectory的含义是获取或设置当前工作路径,而Application.StartupPath是获取程序启动路径,表面上看二者没什么区别,但实际 ...
- UI输入控件
--UI输入控件 -- 输入控件 cc.uii.UIInput.new(table) --[[ 参数 table{ image 输入框图像,可以为图片名或者display.newScale9Sprit ...
- Ajax跨域实现
Ajax Ajax,Asynchronus JavaScript and XML,字母意思:异步的 JavaScript 和 XML,是指一种创建交互式网页应用的网页开发技术.用于异步地去获取XML作 ...
- sql 代码笔记
1. if() 函数 推荐一个学习MySQL的网站 Study MySql
- 两个坑-Linux下Network-Manager有线未托管-DNS resolv.conf文件开机被清空
Linux里面有两套管理网络连接的方案: 1./etc/network/interfaces(/etc/init.d/networking) 2.Network-Manager 两套方案是冲突的,不能 ...
- codeforces754D Fedor and coupons
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...