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 ...
随机推荐
- CSS3学习系列之选择器(四)
使用选择器来插入文字 css2中,使用before选择器在元素前面插入内容,使用after选择器在元素后面插入内容,在选择器的content属性中定义要插入的内容.将content属性值设定为none ...
- java 局部变量几点笔记
1.局部变量的作用时间很短暂,都被存储在方法的栈内存中:2.(没使用static)非静态变量=实例变量:(使用static)静态变量=类变量3.成员变量:类体内定义的变量:4.局部变量有三种:1)形参 ...
- 浅谈WEB编辑器——HBuilder
我自己用过的WEB编辑器有两种:HBuilder和Dreamweaver.这两种编辑器各有各的特点,但是相对来说,我倾向于前者:后者给我的感觉就是功能繁杂,运行起来慢,而且编码的便捷度不高,时不时需要 ...
- 在CentOS7上使用systemctl配置tomcat
最近买了一台阿里云,现在阿里云CentOS都已经支持7了(前面都是使用CentOS6),索性直接使用CentOS7,7上面目前最大区别就是service变成了现在的systemctl,简单的查了一下并 ...
- 一起学习c++11——c++11中的新增的容器
c++11新增的容器1:array array最早是在boost中出现:http://www.boost.org/doc/libs/1_61_0/doc/html/array.html 当时的初衷是希 ...
- jq-toggle
jq-toggle: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...
- c#重起 普通路由器
using DotNet.Utilities;using System;using System.Collections.Generic;using System.Linq;using System. ...
- Python基础入门教程,Python学习路线图
给大家整理的这套python学习路线图,按照此教程一步步的学习来,肯定会对python有更深刻的认识.或许可以喜欢上python这个易学,精简,开源的语言.此套教程,不但有视频教程,还有源码分享,让大 ...
- intellij idea 常用快捷键让你事半功倍
为什么谈这个 工欲善其事必先利其器,键盘流是必须的,快捷键首当其冲,请收下!!! 常用快捷键列表 Live Templates 自定义代码模板 取消屏幕的翻转,可以使用ctrl+alt+左右,进行代码 ...
- Maven搭建Hadoop开发环境
1.安装maven(用于管理仓库,jar包的管理) 1.解压maven安装包 2.把maven添加到环境变量/etc/profile 3.添加maven目录下的conf/setting.xml文件到- ...