LOOPS(hdu 3853)
题意:迷宫是一个R*C的布局,每个格子中给出停留在原地,往右走一个,往下走一格的概率,起点在(1,1),终点在(R,C),每走一格消耗两点能量,求出最后所需要的能量期望
/*
刚开始以为这就是个**题(其实真的是),后来发现我才是**。
我设的dp[i][j]表示走到i,j的期望值,然后写个式子随便转移,后来发现这样写如果p[i][j][1]为1的话,这样转移就GG了。
然后发现题解们设得dp[i][j]表示i,j走到n,m的期望,然后倒着转移,这样就避免了上述情况。
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#define N 1010
using namespace std;
double p[N][N][],dp[N][N];int n,m;
void work(){
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
scanf("%lf%lf%lf",&p[i][j][],&p[i][j][],&p[i][j][]);
dp[n][m]=;
for(int i=n;i;i--)
for(int j=m;j;j--){
if((i==n&&j==m)||p[i][j][]==) continue;
dp[i][j]=(dp[i][j+]*p[i][j][]+dp[i+][j]*p[i][j][]+)/(-p[i][j][]);
}
printf("%.3lf\n",dp[][]);
}
int main(){
while(scanf("%d%d",&n,&m)!=EOF){
memset(dp,,sizeof(dp));
memset(p,,sizeof(p));
work();
}
return ;
}
LOOPS(hdu 3853)的更多相关文章
- 2道acm编程题(2014):1.编写一个浏览器输入输出(hdu acm1088);2.encoding(hdu1020)
//1088(参考博客:http://blog.csdn.net/libin56842/article/details/8950688)//1.编写一个浏览器输入输出(hdu acm1088)://思 ...
- Bestcoder13 1003.Find Sequence(hdu 5064) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5064 题目意思:给出n个数:a1, a2, ..., an,然后需要从中找出一个最长的序列 b1, b ...
- 2013 多校联合 F Magic Ball Game (hdu 4605)
http://acm.hdu.edu.cn/showproblem.php?pid=4605 Magic Ball Game Time Limit: 10000/5000 MS (Java/Other ...
- (多线程dp)Matrix (hdu 2686)
http://acm.hdu.edu.cn/showproblem.php?pid=2686 Problem Description Yifenfei very like play a num ...
- War Chess (hdu 3345)
http://acm.hdu.edu.cn/showproblem.php?pid=3345 Problem Description War chess is hh's favorite game:I ...
- 2012年长春网络赛(hdu命题)
为迎接9月14号hdu命题的长春网络赛 ACM弱校的弱菜,苦逼的在机房(感谢有你)呻吟几声: 1.对于本次网络赛,本校一共6名正式队员,训练靠的是完全的自主学习意识 2.对于网络赛的群殴模式,想竞争现 ...
- BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)
Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- BestCoder Round #68 (div.2) geometry(hdu 5605)
geometry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...
- 2013多校联合2 I Warm up 2(hdu 4619)
Warm up 2 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total ...
随机推荐
- 蓝牙stack bluez学习(1)Stack Architecture
Bluez支持的features Core Specification 4.2 (GAP, L2CAP, RFCOMM, SDP, GATT) Classic Bluetooth (BR/EDR) B ...
- 使用jquery清除select中的所有option
html代码 <select id="search"> <option>baidu</option> <option>sogou&l ...
- React和Vue组件间数据传递demo
一.React (一)父组件向子组件传数据 简单的向下传递参数 /* Parent */ class App extends Component { render() { return ( <d ...
- thinkcmf常用标签
1.图片地址:{:cmf_get_image_url($vo.icon)} 2.模板控件 模板变量调用:$theme_vars.title <widget name="aboutUs& ...
- thinkphp5中php7中运行会出现No input file specified. 这个你改个东西
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{RE ...
- python3.7 文件操作
#!/usr/bin/env python __author__ = "lrtao2010" #python3.7 文件操作 # r 只读,默认打开方式,当文件不存在时会报错 # ...
- Virtual Friends HDU - 3172 (并查集+秩+map)
These days, you can do all sorts of things online. For example, you can use various websites to make ...
- 素数筛选:HDU2710-Max Factor
Max Factor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem ...
- HBase0.94.2-cdh4.2.0需求评估测试报告1.0之二
Hbase 配置文件: hbase-site.xml <configuration> <property> <name>hbase.cluster.distribu ...
- matlab图形handle