刷题总结——Aeroplane chess(hdu4405)
题目:
Problem Description
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.
Input
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.
Output
Sample Input
8 3
2 4
4 5
7 8
0 0
Sample Output
题解:
期望dpsb题···不多说了
代码:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+;
double f[N];
int n,m,to[N];
inline int R(){
char c;int f=;
for(c=getchar();c<''||c>'';c=getchar());
for(;c<=''&&c>='';c=getchar()) f=(f<<)+(f<<)+c-'';
return f;
}
int main(){
//freopen("a.in","r",stdin);
while(scanf("%d%d",&n,&m)){
if(n==&&m==) break;
memset(to,,sizeof(to));memset(f,,sizeof(f));int a,b;
for(int i=;i<=m;i++) a=R(),b=R(),to[a]=b;
for(int i=n-;i>=;i--){
if(to[i]){
f[i]=f[to[i]];continue;
}
for(int j=;j<=;j++)
f[i]+=(f[i+j]+)/;
}
printf("%0.4f\n",f[]);
}
return ;
}
刷题总结——Aeroplane chess(hdu4405)的更多相关文章
- 【刷题】HDU 4405 Aeroplane chess
Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled fr ...
- hdu4405 Aeroplane chess
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- HDU-4405 Aeroplane chess
http://acm.hdu.edu.cn/showproblem.php?pid=4405 看了一下这个博客http://kicd.blog.163.com/blog/static/12696191 ...
- 【HDU4405】Aeroplane chess [期望DP]
Aeroplane chess Time Limit: 1 Sec Memory Limit: 32 MB[Submit][Stataus][Discuss] Description Hzz lov ...
- 【HDOJ】【4405】Aeroplane chess飞行棋
概率DP/数学期望 kuangbin总结中的第4题 啊还是求期望嘛……(话说Aeroplane chess这个翻译怎么有种chinglish的赶脚……) 好像有点感觉了…… 首先不考虑直飞的情况: f ...
- HDU 4405 Aeroplane chess 期望dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Time Limit: 2000/1000 MS (Java/ ...
- LeetCode刷题系列
LeetCode 我们工作面试和提高自身数据结构和算法能力的时候往往需要刷刷题,我选择LeetCode是通过一个留学论坛了解的.专业,覆盖语种全面. 提前说说刷题的心得: 尽量手写代码,少使用IDE的 ...
- ife任务刷题总结(一)-css reset与清除浮动
本文同时发布于本人的个人网站www.yaoxiaowen.com 百度创办的前端技术学院,是一个面向大学生的前端技术学习平台.虽然只有大学生才有资格报名,提交代码进行比赛排名.但是这并不妨碍我们这些初 ...
- 刷题ING...
我用codeVS刷题.. 努力准备!!
随机推荐
- 爱她就用python给她画个小心心 ♥(ˆ◡ˆԅ)
from turtle import * a = Turtle() screensize(400, 300, "blue") setup(width=1300, height=65 ...
- IBM Rational Software Architect V9.0安装图解
IBM Rational Software Architect(RSA) -- IBM软件开发平台的一部分 – 是IBM在2003年二月并购Rational以来,首次发布的Rational产品.改进过 ...
- TP3.2.3 页面跳转后 Cookie 失效 —— 参考解决方案
一.问题描述 接手一个项目,使用ThinkPhp3.2.3,在线上环境( Centos7.4 + Nginx1.14 + MySQL5.7 + PHP7.2.4 )运行没有问题, 在本地环境( php ...
- C# 禁止在textBox输入框输入非法字符
首先添加下面代码 //禁止在textBox输入框输入非法字符 private void keypressed(Object o, KeyPressEventArgs e) { if (e.KeyCha ...
- [Link-Cut-Tree][BZOJ2631]Tree
题面 Description: 一棵\(n\)个点的树,每个点的初始权值为\(1\).对于这棵树有\(q\)个操作,每个操作为以下四种操作之一: + u v c:将\(u\)到\(v\)的路径上的点的 ...
- 11-Json文件配置
1-新建json文件, 设置json文件生成的方式 { "ClassNo": "1", "ClassDesc": "Asp.net ...
- 实时查询引擎 - Facebook Presto 介绍与应用
1. Presto 是什么 Facebook presto是什么,继Facebook创建了HIVE神器后的又一以SQL语言作为接口的分布式实时查询引擎,可以对PB级的数据进行快速的交互式查询.它支 ...
- Android面试收集录6 事件分发机制
转自:秋招面试宝典. 一. 基础认知 1.1 事件分发的对象是谁? 答:事件 当用户触摸屏幕时(View或ViewGroup派生的控件),将产生点击事件(Touch事件). Touch事件相关细节(发 ...
- 4,Flask 中的 request
每个框架中都有处理请求的机制(request),但是每个框架的处理方式和机制是不同的 为了了解Flask的request中都有什么东西,首先我们要写一个前后端的交互 基于HTML + Flask 写一 ...
- 当Hadoop 启动节点Datanode失败解决
Hadoop 启动节点Datanode失败解决 [日期:2014-11-01] 来源:Linux社区 作者:shuideyidi [字体:大 中 小] 当我动态添加一个Hadoop从节点的之后,出现 ...