HDU3853:LOOPS(概率dp & 期望)

插头DP && 概率DP / 期望DP 插头DP && 概率DP / 期望DP写在前面:插头DPP5056 【模板】插头dp手写哈希表的方法:拉链法的代码如下:开放寻址法的代码如下:接下来是这道题的代码实现:P3190 [HNOI2007]神奇游乐园具体的代码实现如下:P3272 [SCOI2011]地板具体的代码实现如下:期望DPUVA12230 过河 Crossing Rivers具体的代码实现如下:期望dp / 概率dp的概念:期望DP / 概率DP常见的状态表示及其转移:SP1026 FAVDICE - Favorite 阅读详情

LOOPS

Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others)
Total Submission(s): 6443    Accepted Submission(s): 2583


Problem Description
Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl).

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.




 

Input
The first line contains two integers R and C (2 <= R, C <= 1000).

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


 

Output
A real number at 3 decimal places (round to), representing the expect magic power Homura need to escape from the LOOPS.

 

Sample Input
  
2 2 0.00 0.50 0.50 0.50 0.00 0.50 0.50 0.50 0.00 1.00 0.00 0.00
 

Sample Output
  
6.000
 

Source
 
题意:一个N*M的房间,主角在1,1点,每次使用2个魔法可以触发当前房间的传送门,每个房间有概率p1 p2  p3分别是停留在原地,进入右边的房间,进入下边的房间,问到达N M点的期望魔法数。

思路:易推得dp(x,y) = p1dp(x,y)+p2dp(x+1,y)+p3dp(x,y+1)+2;
dp(x,y)= (p2dp(x+1,y)+p3dp(x,y+1)+2)/(1-p1); 还有一种情况,停在原地的概率为1的话,这个房间跳过即可。

# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstring>
using namespace std;
const int maxn = 1e3+8;
double a[maxn][maxn], b[maxn][maxn], c[maxn][maxn], dp[maxn][maxn];
int main()
{
    int n, m;
    while(~scanf("%d%d",&n,&m))
    {
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=m; ++j)
                scanf("%lf%lf%lf",&a[i][j],&b[i][j],&c[i][j]);
        dp[n][m] = 0;
        for(int i=n; i>0; --i)
        {
            for(int j=m; j>0; --j)
            {
                if(i==n&&j==m) continue;
                if(fabs(1-a[i][j])<1e-7) continue;//进入了这点就走不出去。
                dp[i][j] = (b[i][j]*dp[i][j+1]+c[i][j]*dp[i+1][j]+2)/(1-a[i][j]);
            }
        }
        printf("%.3f\n",dp[1][1]);
    }
    return 0;
}



概率DP入门总结 16题 概率dp小总结 16题 阅读详情

相关推荐

A New Approach To Set Point Control In Chilled Water Loops

这是一篇值得看的论文,值得研究,或许你能找到你想要的

【HDU3853】LOOPS 期望与概率

Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka save the world. But because of the plot of the Boss Incubator, she is trapped in...

Tmotfl的博客 368

PaddleOCR实战:如何在CentOS 8.5上搭建高性能OCR识别环境

本文详细介绍了在CentOS 8.5系统上搭建高性能PaddleOCR识别环境的完整指南。从系统环境准备、PaddlePaddle框架部署到PaddleOCR的定制化安装与性能优化,提供了针对生产环境的解决方案,包括GPU/CPU环境配置、内核参数调优及常见问题排查,帮助用户实现高效OCR识别。

weixin_29223603的博客 356

[HDU] 3853 LOOPS 期望dp入门

Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl).Homura wants to help her friend Madoka save the world. But because of the plot of the Boss Incubator, she is trapped in a

Le Petit Prince 420

VPI与Matlab协同仿真:相干光通信接收端DSP算法全解析

本文详细解析了如何利用VPI与Matlab协同仿真,构建完整的相干光通信接收端DSP算法处理闭环。重点介绍了从VPI导出数据后,在Matlab中实现时钟恢复、偏振解复用和载波相位估计等核心算法的步骤与原理,并阐述了如何通过误码率计算完成仿真验证,为相干光通信系统算法研究与验证提供了高效实用的方法。

ll5678的博客 614

MicroBlaze系列教程(5):AXI_UART16550的使用

axi-uart16550是Xilinx的一款串口IP核,支持配置成16450或16550模式,16550和16450是指的早期电脑主板上的串口芯片型号,16550相比于16450多了FIFO,现在已经很少使用。相比于,16550支持1或2位停止位,包括uartlite所有的功能,而且支持在SDK中灵活对波特率、数据、校验方式进行配置。与uartlite不同的是,不能单独指定发送中断和接收中断函数,只有一个中断函数,通过event参数来区分当前是发送或接收中断。

whik1194的博客 4560

HDU 3853 LOOPS(概率DP)

  LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others)Total Submission(s): 649    Accepted Submission(s): 267 Problem Description Akemi Homura is a Mahou Sho...

weixin_34124577的博客 233

全功能tgbot/Telegram机器人多功能有后台版源码

trx兑换 闪兑 关键字监控 群管 usdt监控 余额查询 推广分享 等几乎常见的tg机器人功能都有。全功能tgbot/telegram机器人多功能有后台版源码-打包好的可以直接上手。

百创科技 2724

文章标题 HDU 3853:LOOPS (概率DP)

LoopsDescriptionAkemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka save the world. But because of the plot of the Boss Incubator, she is trapped in a laby

Wang_SF2015的博客 481

uniapp - H5网页打包运行报错Failed to load resource: net::ERR_FILE_NOT_FOUND(uniApp打包成H5部署到服务器,打包h5白屏并报错页面空白)

Failed to load resource: net::ERR_FILE_NOT_FOUND,uniapp 坑之打包之后白屏,uniapp打包h5,HBuilderX 打包H5后空白报错 Failed to load resource: net::ERR FILE NOT_FOUND,UNI-APP H5应用白屏(空白页)解决方案,白屏并报错Failed to load resource: net::ERR_FILE_NOT_FOUND,uniapp开发,打包成H5部署到服务器,uniapp打包之后首页

🏆 前端领域优质创作者 3584

CMake入门教程【基础篇】CMake+Visual Studio2022构建C++项目

CMake+Visual Studio2022搭建C++环境

小鱼酱的博客 4975

HDU3853 LOOPS 概率DP数学期望

HDU3853 LOOPS 概率DP 题目大意: 给出一个n * m的矩阵,要求从左上角走到右下角,每次移动消耗两点能量,并且每次的移动方向是有概率的(回到自身,往右或者往下)。输入的矩阵中的每个位置有三个数,分别表示回到自身、向右移动、向下移动的概率,三者概率和为1,要求输出从左上角走到右下角需要消耗的能量值的期望。(测试数据可能有点问题,会出现回到自身的概率为1从而导致死循环的情况) 解题思路...

qq_43710979的博客 976

数据权限设计

随着IT新技术不断完善成熟,企业数字化建设得到全面的发展,数据将成为一个创造财富的重要来源,并且越来越多地被视为一项值得重视的企业资产。未来,很多企业之间的竞争,其实也是资源和数据竞争。那么针对数据资产,如何保障它的安全性呢?数据的权限管理无疑是必不可少的。数据权限从数据源来控制不同的用户能够查看、使用和授权不同的数据表数据(其实就是数据表行列的管控),就如同筑起了一道道护城墙,为数据安全提供了保障。

qq_40664711的博客 1万+

HDU 3853 LOOPS (概率DP)

HDU 3853 LOOPS (概率DP)http://acm.hdu.edu.cn/showproblem.php?pid=3853 题面: LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Submission(s): 4567   

而濡木染 939

自然语言处理NLP星空智能对话机器人系列:Gavin大咖 Transformer 101问答集 第一问

自然语言处理NLP星空智能对话机器人系列:Transformer 101问答 [让天下没有难学的Transformer] 你问我答系列之一 Gavin大咖第一问: Transformer中的可训练Queries、Keys和Values矩阵从哪儿来? 以上是智华解答,供同学们参考。 星空智能对话机器人系列博客 NLP星空智能对话机器人系列:第二次星空智能对话机器人Zoom线上演示安排 NLP星空智能对话机器人系列:StarSpace: Embed All The Things NLP星空智能对

大模型与Agent智能体 996

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

HDU 3853 LOOPS(概率dp 求期望)

HDU 3853 LOOPS(概率dp 求期望)

1256

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

简单概率dp(期望)-hdu-3853-LOOPS

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3853 题目大意: 给一个r*c的矩阵,每个格子(x,y),用2魔法值就可以走一步,(可以到(x,y)、(x+1,y)、(x,y+1)),告诉每个格子的能到达的三个位置的概率,求从左上角到达右下角所需魔法值的期望。 解题思路: 简单期望dp. dp[i][j]表示从位置(i,j)到达终

cc_again的专栏 2374

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

HDU3853:LOOPS

又是被HDU针对的一天HDU3853:LOOPS题目大意思路代码~~又被HDU封印了~~ 题目大意 传送门 思路 我们可以设dp[i][j]dp[i][j]dp[i][j]表示(i,j)(i,j)(i,j)到终点的期望能量,那么dp[i][j]=dp[i][j+1]×pro[i][j][1](走到这个点的概率)+dp[i+1][j]×pro[i][j][2]+dp[i][j]×pro[i][j]...

nobody_like_you的博客 277

HDU 3853 LOOPS(概率dp求期望)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka save the world. But be...

1568

HDU 3853 LOOPS:期望dp【网格型】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 题意:   有一个n*m的网格。   给出在每个格子时:留在原地、向右走一格,向下走一格的概率。   每走一格会消耗2点体力。   问你从(1,1)到达终点(n,m)消耗体力的期望。 题解:   表示状态:     dp[i][j] = rest steps(剩余...

a1392136的博客 259

hdu3853 LOOPS 概率dp求期望

题意:给定一个n*m的方格,给出相应( i , j ) 原地、往下 、往右走的概率,每走一格花费魔法值2,求从起始点(1,1)到(n,m)花费魔法值的期望 思路:设dp[ i ][ j ]为从(i , j)出发到达目标状态(n , m)所需魔法值的期望。dp[ i ][ j ]有3种转移方式: (1)dp[ i ][ j ] -------> dp[ i ][ j ],转移概率为p1; (2

AC_kereo的专栏 1355

HDU 3853 LOOPS [简单概率DP]

Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). —— 给出一个矩阵,每个点每一步有P0的概率在原点,P1的概率向右走,P2的概率向左走,问从左上角走到右下角的期望步数。

Asuna_acmer 767

HDU 3853 LOOPS 概率DP 期望

题意:在(i,j)(i,j)处的点有rate(i,j,1)rate_{(i,j,1)}的概率留在(i,j)(i,j)处,有rate(i,j,2)rate_{(i,j,2)}的概率走向(i,j+1)(i,j+1)处,有rate(i,j,3)rate_{(i,j,3)}的概率走向(i+1,j)(i+1,j)处,走一步需要花费2,问从(1,1)(1,1)走到(n,m)(n,m)处花费的期望是多少?思路:期

NM的专栏 368

hdu 3853 LOOPS(期望)

http://acm.hdu.edu.cn/showproblem.php?pid=3853 求从【1,1】到【r,c】的所花power的期望,每走一步消耗的power是2,给出从[i,j]到[i,j],[i,j+1],[i+1][j]概率。 dp[i][j]表示从[i,j]到[r,c]的消耗power的期望,已知终态dp[r][c] = 0,然后逆推。 很难想的是当在原地的

1011

hdu 3853 LOOPS 概率dp

题目大意 有一个人被困在一个 R*C(2 简单的求期望,弄懂求期望和求概率的区别就好很多了 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka save the world.

u013087645的专栏 916

HDU 3853-LOOPS【期望DP】

题意:有一个R*C的迷宫,从(1,1)走到(R,C),每个格子给出停留在原地,向右走一格和向下走一格的概率,且每走一步需要2点能量,求最后所需要的能量期望。 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3853 思路:f[i][j] 就表示走到(i, j) 这个点的期望能量,那么转移方程不难想到,这题主要有两个需要注意的地方,一是停留在原地的花...

独钓门前月 656
上一篇: HDU4405:Aeroplane chess(概率dp & 期望)
下一篇: CFgym:Painting the Wall(BFS)
junior19
博客等级 码龄10年 118粉丝 615原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值