HDU-4405 Aeroplane chess
http://acm.hdu.edu.cn/showproblem.php?pid=4405
看了一下这个博客http://kicd.blog.163.com/blog/static/126961911200910168335852/
Aeroplane chess
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1336 Accepted Submission(s): 913
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.
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int f[];
double e[];
int main()
{
int i,a,b,n,m;
while(~scanf("%d%d",&n,&m))
{
if(n==&&m==)
break;
memset(f,,sizeof(f));
memset(e,,sizeof(e));
for(i=;i<=m;i++)
{
scanf("%d%d",&a,&b);
f[a]=b;
}
e[n]=;
for(i=n-;i>=;i--)
{
if(f[i]!=)
e[i]=e[f[i]];
else
e[i]=1.0/*(e[i+]+e[i+]+e[i+]+e[i+]+e[i+]+e[i+])+;
}
printf("%.4lf\n",e[]);
}
return ;
}
HDU-4405 Aeroplane chess的更多相关文章
- HDU 4405 Aeroplane chess 期望dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Time Limit: 2000/1000 MS (Java/ ...
- hdu 4405 Aeroplane chess(简单概率dp 求期望)
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 4405 Aeroplane chess (概率DP)
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 4405 Aeroplane chess(概率+dp)
Problem Description Hzz loves aeroplane chess very much. The chess map contains N+ grids labeled to ...
- [ACM] hdu 4405 Aeroplane chess (概率DP)
Aeroplane chess Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 ...
- 【刷题】HDU 4405 Aeroplane chess
Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled fr ...
- HDU 4405 Aeroplane chess 概率DP 难度:0
http://acm.hdu.edu.cn/showproblem.php?pid=4405 明显,有飞机的时候不需要考虑骰子,一定是乘飞机更优 设E[i]为分数为i时还需要走的步数期望,j为某个可能 ...
- HDU 4405 Aeroplane chess(期望)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:从0走到n,每次走之前掷一次筛子,掷出几点就向前走几点,走到大于等于n的地方就停止.但是, ...
- HDU 4405 Aeroplane chess:期望dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意: 你在下简化版飞行棋... 棋盘为一个线段,长度为n. 上面有m对传送门,可以直接将你从a ...
- HDU 4405 Aeroplane chess (概率DP)
题意:你从0开始,要跳到 n 这个位置,如果当前位置是一个飞行点,那么可以跳过去,要不然就只能掷骰子,问你要掷的次数数学期望,到达或者超过n. 析:概率DP,dp[i] 表示从 i 这个位置到达 n ...
随机推荐
- .net单元测试——解除依赖
最近在看.net单元测试艺术,我也喜欢单元测试,这里写一下如何在测试中解除对象间的依赖. 假如有这样的一个需求,当用户登陆时,我需要对用户名和密码进行验证,然后再将用户名写入日志中. public c ...
- .NET性能优化方面的总结
从2004年底开始接触C#到现在也有2年多的时间了,因为有C++方面的基础,对于C#,我习惯于与C++对比.现在总结一些.NET方面的性能优化方面的经验,算是对这两年多的.NET工作经历的总结. ...
- 看es6 字符串新方法有感
'x'.repeat(3) // "xxx" 'hello'.repeat(2) // "hellohello" 'na'.repeat(0) // " ...
- 十进制和n进制的转换(10进制转换为36进制)
答案如下: void Convert() { map<int ,string> maps; maps[0]="0"; maps[1]="1"; ma ...
- VC皮肤库之duilib
首先是个国产的开源 的,directui 界面库,开放,共享,惠众,共赢,遵循bsd协议,可以免费用于商业项目,目前支持Windows 32 .Window CE.Mobile等平台. Duilib ...
- Sevlet局部变量初始化
//java 代码部分package com.servlet; import java.io.IOException; import java.io.PrintWriter; import java. ...
- WPF实现导航的几种方式
下面是展示的是几种导航方式: 我们来具体看下xaml文件 <Page x:Class="WPF实现Navigation.Page1" xmlns="http://s ...
- C# 下载资源
//创建一个初始化请求对象 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("http://wwww.b ...
- FutureTask源码解读
import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.ut ...
- cygwin使用
Cygwin是一个在windows平台上运行的类UNIX模拟环境,是cygnus solutions公司开发的自由软件(该公司开发的著名工具还有eCos,不过现已被Redhat收购). 它对于学习UN ...