HDU - 3853
LOOPS
Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others)
Total Submission(s): 6423 Accepted Submission(s): 2572
Homura wants to help her friend Madoka save the world. But because of the plot of the Boss Incubator, she is trapped in a labyrinth called LOOPS.
The planform of the LOOPS is a rectangle of R*C grids. There is a portal in each grid except the exit grid. It costs Homura 2 magic power to use a portal once. The portal in a grid G(r, c) will send Homura to the grid below G (grid(r+1, c)), the grid on the right of G (grid(r, c+1)), or even G itself at respective probability (How evil the Boss Incubator is)!
At the beginning Homura is in the top left corner of the LOOPS ((1, 1)), and the exit of the labyrinth is in the bottom right corner ((R, C)). Given the probability of transmissions of each portal, your task is help poor Homura calculate the EXPECT magic power she need to escape from the LOOPS.
The following R lines, each contains C*3 real numbers, at 2 decimal places. Every three numbers make a group. The first, second and third number of the cth group of line r represent the probability of transportation to grid (r, c), grid (r, c+1), grid (r+1, c) of the portal in grid (r, c) respectively. Two groups of numbers are separated by 4 spaces.
It is ensured that the sum of three numbers in each group is 1, and the second numbers of the rightmost groups are 0 (as there are no grids on the right of them) while the third numbers of the downmost groups are 0 (as there are no grids below them).
You may ignore the last three numbers of the input data. They are printed just for looking neat.
The answer is ensured no greater than 1000000.
Terminal at EOF
0.00 0.50 0.50 0.50 0.00 0.50
0.50 0.50 0.00 1.00 0.00 0.00
#include<cstdio>
#include<cstring>
#include<cmath>
const double eps=1e-; struct node
{
double a,b,c;
} w[][]; double dp[][]; int main()
{
int r,c;
while(~scanf("%d%d",&r,&c))
{
for(int i=; i<=r; i++)
for(int j=; j<=c; j++)
scanf("%lf%lf%lf",&w[i][j].a,&w[i][j].b,&w[i][j].c);
dp[r][c]=;
for(int i=r; i>=; i--)
for(int j=c; j>=; j--)
if(fabs(-w[i][j].a)>eps)
dp[i][j]=(w[i][j].b*dp[i][j+]+w[i][j].c*dp[i+][j]+)/(-w[i][j].a);
printf("%.3lf\n",dp[][]);
}
return ;
}
HDU - 3853的更多相关文章
- 概率dp HDU 3853
H - LOOPS Time Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ci ...
- HDU 3853:LOOPS(概率DP)
http://acm.split.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Problem Description Akemi Homura is a M ...
- HDU 3853 LOOPS 期望dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Time Limit: 15000/5000 MS (Java/Others)Me ...
- HDU 3853 LOOPS:期望dp【网格型】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 题意: 有一个n*m的网格. 给出在每个格子时:留在原地.向右走一格,向下走一格的概率. 每走一 ...
- hdu 3853(数学期望入门)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Time Limit: 15000/5000 MS (Java/Others) ...
- AC日记——LOOPS hdu 3853
3853 思路: 概率dp求期望: 代码: #include <cstdio> #include <cstring> #include <iostream> usi ...
- HDU 3853(期望DP)
题意: 在一个r*c的网格中行走,在每个点分别有概率向右.向下或停止不动.每一步需要的时间为2,问从左上角走到右下角的期望时间. SOL: 非常水一个DP...(先贴个代码挖个坑 code: /*== ...
- LOOPS(HDU 3853)
LOOPS Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others)Total Sub ...
- hdu 3853 LOOPS(基础DP求期望)
题目大意 有一个人被困在一个 R*C(2<=R,C<=1000) 的迷宫中,起初他在 (1,1) 这个点,迷宫的出口是 (R,C).在迷宫的每一个格子中,他能花费 2 个魔法值开启传送通道 ...
- hdu 3853 LOOPS 概率DP
简单的概率DP入门题 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include ...
随机推荐
- Primeton BPS 6.7+MyEclipse_5.5.1GA_E3.2.2插件安装
准备 Primeton_BPS_6.7_Developer MyEclipse5.5插件版 BPS安装 MyEclipse插件安装 点击MyEclipse_5.5.1GA_E3.2.2_Install ...
- python 标准库 -- signal
signal 的核心是 : 设置信号处理函数. 预定义信号 signal.SIG_DFL signal.SIGBUS signal.SIGFPE signal.SIGIO signal.SIGPOLL ...
- Solr6.6 Tomcat8部署
原文:https://github.com/x113773/testall/issues/6 准备工作:[solr-6.6.0](http://www.apache.org/dyn/closer.lu ...
- [leetcode-629-K Inverse Pairs Array]
Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that ...
- Android如何实现定位获取
一:GPS定位: (1).要实用Adnroid平台的GPS设备,首先需要添加上权限,所以需要添加如下权限: uses-permission android:name= android.permissi ...
- 暂停和播放CSS3动画的两种实现方法
1,直接修改animationPlayState <!DOCTYPE html> <html> <head lang="en"> <met ...
- Sass控制命令及函数知识整理
2017-07-07 20:17:17 最底部附结构图(实在是结构图太长了没办法) 2017-06-22 09:11:43 一.Sass的控制命令 1.@if语句 @if 指令是一个 SassSc ...
- JavaScript 原型与继承机制详解
引言 初识 JavaScript 对象的时候,我以为 JS 是没有继承这种说法的,虽说 JS 是一门面向对象语言,可是面向对象的一些特性在 JS 中并不存在(比如多态,不过严格来说也没有继承).这就困 ...
- Java的基本数据类型和运算
编码 ASCII--0~127 65-A 97-a 西欧码表---ISO-8859-1---0-255---1个字节 gb2312----0-65535---gbk---2个字节 Unicode编 ...
- mysql sql 基础总结
1 mysql top n使用 select * from table limit n; 2 统配符使用必须和like结合使用 like % 通配符 描述 % 替代一个或多个字符 _ 仅替代一个 ...