HDU 4035 Maze [概率DP]

【YOLOs-CPP-图像分类部署】04-项目优化(加速部署) 本文详细介绍了将YOLO图像分类C++部署项目从CMake迁移到Visual Studio控制台应用的全过程。针对低配CPU性能瓶颈问题,作者通过替换多线程HPP代码为官方实现,并采用448x448固定输入尺寸优化推理速度。项目配置包含OpenCV和ONNX Runtime环境设置,实现了图像批量处理、分类结果显示及结果日志输出功能。关键步骤包括依赖库配置、DLL部署和代码调试,最终在Windows平台成功实现高效CPU推理。该方案显著提升了低配硬件的兼容性,为图像分类任务提供了稳定的部署解决方案。 阅读详情

Description

When wake up, lxhgww find himself in a huge maze. 

The maze consisted by N rooms and tunnels connecting these rooms. Each pair of rooms is connected by one and only one path. Initially, lxhgww is in room 1. Each room has a dangerous trap. When lxhgww step into a room, he has a possibility to be killed and restart from room 1. Every room also has a hidden exit. Each time lxhgww comes to a room, he has chance to find the exit and escape from this maze. 

Unfortunately, lxhgww has no idea about the structure of the whole maze. Therefore, he just chooses a tunnel randomly each time. When he is in a room, he has the same possibility to choose any tunnel connecting that room (including the tunnel he used to come to that room). 
What is the expect number of tunnels he go through before he find the exit? 

题意:

给出一个迷宫,路径为一棵树,树上有N个节点,从1出发,每走到一个节点可能会发生三种事件:

Ki的概率发生被杀回到起点1;

Ei的概率发生成功逃出迷宫;

剩下的概率发生随机选择一条路径到下一个节点。(等概率选择)

问逃出迷宫前需要走的步数的期望值。


范围:

N<=10000,30组样例


解法:

范围很明显表示时间复杂度为On或者On*logn,考虑概率DP,DP[I]表示从I点出发,需要走的步数的期望值,目标是求解DP[1]。

那么很明显这个转移过程是由环的,需要设未知数,首先列出转移方程:

DP[I]=Ki*DP[1]+(1-Ki-Ei)/M *(ΣDP[son] +DP[father])+1-Ki-Ei

发现应该自底向上DP,所以对于I来说DP[SON]是已知的,其他都是未知的,所以方程转换为:

DP[I]=A[i]*DP[i] + B[i]*DP[father] + C[i]

根据原方程得出A,B,C的转移方程:

设P=(1-k[I]-E[I])/ M ,M为连出去的边数,即P为走其中一条边的概率

A[I]=K[I]+P*ΣA[son];

B[I]=P

C[I]=1-K[I]-E[I]+P*ΣC[son]

最后得到等式DP[1]=A[1]*DP[1]+C[1]

化简得:

DP[1]=C[1]/(1.0-A[1])

可知A[1]→1.0时,无解


代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdlib.h>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<bitset>
#pragma comment(linker, "/STACK:1024000000,1024000000")
template <class T>
bool scanff(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
#define inf 1073741823
#define llinf 4611686018427387903LL
#define PI acos(-1.0)
#define lth (th<<1)
#define rth (th<<1|1)
#define rep(i,a,b) for(int i=int(a);i<=int(b);i++)
#define drep(i,a,b) for(int i=int(a);i>=int(b);i--)
#define gson(i,root) for(int i=ptx[root];~i;i=ed[i].next)
#define tdata int testnum;scanff(testnum);for(int cas=1;cas<=testnum;cas++)
#define mem(x,val) memset(x,val,sizeof(x))
#define mkp(a,b) make_pair(a,b)
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define pb(x) push_back(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


#define NN 10010
double dp[NN];
double a[NN],b[NN],c[NN],k[NN],e[NN];
int ptx[NN],lnum,n;
struct edge{
    int v,next;
    edge(){}
    edge(int v,int next):v(v),next(next){}
}ed[NN*2];
void addline(int x,int y){
    ed[lnum]=edge(y,ptx[x]);
    ptx[x]=lnum++;
}
void init(){
    lnum=0;
    rep(i,0,n)dp[i]=a[i]=b[i]=c[i]=0;
    rep(i,0,n)ptx[i]=-1;
}

void dfs(int x,int fa){
    double ta,tb,tc;
    ta=tb=tc=0;
    int m=(x==1?0:1);
    gson(i,x){
        int y=ed[i].v;
        if(y==fa)continue;
        dfs(y,x);
        m++;
        ta+=a[y];
        tb+=b[y];
        tc+=c[y];
    }
    double p=(1.0-k[x]-e[x])/double(m);
    if(x==1){
        a[x]=k[x]+ta*p+tb*p;
        c[x]=1.0-k[x]-e[x]+tc*p;
        return;
    }
    if(m==1){
        a[x]=k[x];
        b[x]=p;
        c[x]=1.0-k[x]-e[x];
    }
    if(m!=1){
        a[x]=k[x]+ta*p;
        b[x]=p;
        c[x]=1.0-k[x]-e[x]+tc*p;
    }
    a[x]/=(1.0-tb*p);
    b[x]/=(1.0-tb*p);
    c[x]/=(1.0-tb*p);
}

int main(){
    tdata{
        scanff(n);
        init();
        rep(i,1,n-1){
            int x,y;
            scanff(x);scanff(y);
            addline(x,y);
            addline(y,x);
        }
        rep(i,1,n){
            scanff(k[i]);scanff(e[i]);
            k[i]/=100.0;e[i]/=100.0;
        }
        dfs(1,0);
        double ans=c[1]/(1.0-a[1]);
        double eps=1e-9;
        printf("Case %d: ",cas);
        if(fabs(a[1]-1.0)<eps)printf("impossible\n");
        else printf("%lf\n",ans);
    }
}










手把手教你在飞牛 NAS 上部署自有图床,含Python调用接口 📸 想在飞牛 NAS 上部署图床?这篇教程超适合小白!从安装到使用,步骤清晰~ 阅读详情

相关推荐

CGNS快速入门到实战(二):VS配置调用CGNS静态链接库

CGNS快速入门到实战这一系列分成三篇文章展开叙述,具体有:(一)CGNS静态链接库编译;(二)VS配置调用CGNS静态链接库;(三)CGNS文件及案例展示。本篇文章重点讲述VS配置调用CGNS静态链接库。

ahang_99的博客 2616

hdu 5001 从任意点出发任意走d步不经过某点概率

http://acm.hdu.edu.cn/showproblem.php?pid=5001 给定n个点m条边的无向图问从任意点出发任意走d步,从不经过某个点的概率 本想先算路过每个点的概率然后用1减去这个概率 但是由于可以重复路过 所以无法判断是不是第一次经过这个点 所以我们应该直接做不路过的概率 即类似bfs的一步步走 如果走到了要计算的点就停下来 意思...

weixin_30273763的博客 164

FMEA-MSR步骤三:功能分析

目的 FMEA-MSR功能分析的主要目标: ● 功能及各功能之间的关系的可视化 ● 功能树/网络或等效功能矩阵参数图(P图) ● 顾客(外部和内部)功能与相关要求的关联 ● 要求或特性与功能的关联 ● 工程团队(系统、安全和组件)之间的协作 ● 失效分析步骤的基础 (点击链接进入官网领取软件试用) 在监视及系统响应的补充FMEA中,对失效探测和失效响应的监视视为其具有的功能。硬件和软件功能可能包括监视控制状态的功能。 故障/失效的监视和探测功能可能包括超出范围的探测、循环冗余校验、真实性检查和序列计数器检查

Infomass的博客 2390

Maze (HDU-4035)概率DP

When wake up, lxhgww find himself in a huge maze. The maze consisted by N rooms and tunnels connecting these rooms. Each pair of rooms is connected by one and only one path. Initially, lxhgww is in ro...

菜鸡的博客 312

MoveIt2项目想换掉KDL求解器?试试这个trac_ik插件(附源码编译避坑指南)

本文详细介绍了如何在MoveIt2项目中用trac_ik插件替代KDL求解器,提升机械臂运动学求解的效率和成功率。内容涵盖环境准备、源码编译避坑、项目集成及性能调优,特别适合需要高精度控制的协作机械臂应用场景。通过实测数据对比,trac_ik在求解时间和奇异点处理上显著优于传统KDL求解器。

weixin_30730053的博客 692

大白话讲解Numpy中什么是一维、二维、三维数组,以及5种创建方式

NumPy中提供了多种创建数组的方式,其中最基本的方式就是通过array()函数创建数组在使用该函数时直接传入列表或元组即可。 通过array()函数分别创建一维数组、二维组和三维数组,那么什么是维度呢?一维、二维、三维有什么区别? 1、什么是维度? 维度可以理解为描述数据的一种 “方向” 或者 “层次”。在数组中,维度的数量决定了我们需要用多少个索引来访问一个元素 2、一维、二维、三维的区别? (1)一维:一维数组就像是一条直线上排列的一组数据,例如: a = np.array([1, 2

1362

hdu 4035 Maze 概率dp

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1678    Accepted Submission(s): 639 Special Judge Problem Description When wake

smz436487的专栏 518

【机器学习实战中阶】音乐流派分类-自动化分类不同音乐风格

数据下载地址:https://www.kaggle.com/datasets/andradaolteanu/gtzan-dataset-music-genre-classification/data背景音乐。专家们长期以来一直在尝试理解声音以及是什么使一首歌曲与另一首不同。如何可视化声音。是什么使一个音调与另一个不同。这个数据集希望能提供实现这些目标的机会。内容原始流派 - 包含10种流派,每种流派有100个音频文件,每个文件长度为30秒(著名的GTZAN数据集,声音的MNIST)

2145

【HDU4035】【Maze】【概率dp】【数列求和】

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 2058    Accepted Submission(s): 828 Special Judge Problem Description When wake

ACM之路 396

MSP430FR6043超声波传感器设计记录

1.前言 最近项目设计了一个超声波传感器 参考TI官方的板子EVM430-FR6043搭建的电路 EVM430-FR6043评估模块是一个用于评估MSP430FR6043 MCU性能的开发平台。 MSP430FR6043 MCU是一款超低功耗器件, 集成了超声波感测模拟前端 用于精确地进行超声波测量。 专为超声波水表、热量计和燃气表而设计, MSP430FR6043 器件采用低功耗加速器 (LEA), 可实现基于高速 ADC 的信号采集以及后续优化数字信号处理, 为电池供电型计量提供了一款超低功耗、高

bingdund的博客 2865

IEC61850规约客户端软件开发实战(第二章)

本文介绍了基于IEC61850规约的客户端软件开发过程,重点阐述功能界面设计和服务端连接功能的实现。界面采用Qt框架设计,包含功能按钮区、数据模型展示区(使用QTreeWidget)和状态显示区。连接功能通过libiec61850开源库实现,详细说明了连接流程、句柄创建及状态管理的代码实现。测试结果表明系统能正确识别连接状态,并通过界面直观显示。文章为IEC61850规约软件开发提供了实用参考,下期将分享规约模型数据加载的实现过程。

半青年的博客 2855

[HDU4035] Maze(概率DP)

HDU4035 有\(n\)个房间 , 由\(n-1\)条隧道连通起来 , 实际上就形成了一棵树 , 从结点\(1\)出发 , 开始走 , 在每个结点\(i\)都有\(3\)种可能 : \(1.\)被杀死 , 回到结点\(1\)处 (概率为\(k_i\)) \(2.\)找到出口 , 走出迷宫 (概率为\(e_i\)) \(3.\)和该点相连有\(m\)条边 , 随机走一条 求走出迷宫所要走的边数的...

weixin_30725315的博客 136

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

HDU - 4035 Maze(概率dp)

题目链接:点击查看 题目大意:给出一个 n 个点的树,初始时位于点 1 ,每个点都会给出一个概率 k[ i ] 和一个概率 e[ i] ,其代表的意义分别是: k[ i ] :在点 i 有 k[ i ] 的几率死亡,复活到点 1 e[ i ] :在点 i 有 e[ i ] 的几率逃生 1 - k[ i ] - e[ i ] :等概率经过周围的边到达相邻的点 问从点 1 开始逃生的期望步数 题目分析: 树形dp维护一下概率dp所需要的变量即可,记得特判无解的情况,有个小坑就是会卡精度,e.

Falcon的博客 747

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

HDU 4035 Maze (概率DP)

题目; LINK 题意:     有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树,     从结点1出发,开始走,在每个结点i都有3种可能:         1.被杀死,回到结点1处(概率为ki)         2.找到出口,走出迷宫 (概率为ei)         3.和该点相连有m条边,随机走一条 (概率1 - ki - ei)     求:走出迷宫所要走的边数的期望

Napoleon 918

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

hdu 4035 Maze (树上的概率dp)

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1672    Accepted Submission(s): 635 Special Judge Problem Description When

To be what you what to be! 1189

HDU 4035 Maze(概率dp)

这个

Hardbird 595

hdu4035 Maze(概率dp)

hdu4035题目一颗树形的迷宫,对于每个房间,有几率被杀回到房间1,有几率逃出去,有几率随机到相邻的房间,问逃出去的概率。思路http://www.cnblogs.com/kuangbin/archive/2012/10/03/2711108.html 推公式的概率dp,精妙之处在于E[i] = ki*E[1] + ei*0 + (1-ki-ei)/m*( E[father[i]]+1 + ∑(

天道酬勤 477

HDU 4035 Maze——概率dp

题意: 有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树,  从结点1出发,开始走,在每个结点i都有3种可能: 1.被杀死,回到结点1处(概率为ki) 2.找到出口,走出迷宫 (概率为ei) 3.和该点相连有m条边,随机走一条 求:走出迷宫所要走的边数的期望值。 思路: 设 E[i]表示在结点i处,要走出迷宫所要走的边数的期望。E[1]即为所求。 叶子结点: E[i] = ki*E[1] ...

hao_zong_yin的博客 404

HDU 4035 Maze (很好的概率DP)

做了有些概率和期望的题目了,现在觉得大致有那么两种办法。【说白了还是要靠数学 一、直接利用组合计数求解。 二、通过状态转移列出方程来,如果能递推就直接DP,不能的话,通过对式子处理,找出式子之间的关系和结构上的特点,通过待定系数来进行迭代,最后求出结果。 。。。再有的话就是用容斥啊状压啊什么的【估计自己也不一定想得到 言归正传来说题吧,我把自己的思路写在注释里了。 参考题解:点击

Neutralzz的博客 360

HDU4035 Maze (概率DP)

转:https://www.cnblogs.com/kuangbin/archive/2012/10/03/2711108.html 题意: 有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树, 从结点1出发,开始走,在每个结点i都有3种可能: 1.被杀死,回到结点1处(概率为ki) 2.找到出口,走出迷宫 (概率为ei) 3.和该点...

weixin_30337251的博客 149

HDU 4035 Maze(树形概率DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4035 题意:一棵树,从结点1出发,在每个结点 i 都有3种可能:(1)回到结点1 , 概率 Ki;(2)结束,概率 Ei;(3)随机走一条边。(Ki+Ei+随机走=1) 求到结束需要走的边数的期望。 思路:设Q[i]表示从i到结束的期望,设Q[i]=A[i]*Q[1]+B[i]*Q[fa[i]]+...

weixin_33721344的博客 144

【HDU4035】【Maze】【概率dp】

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 2059    Accepted Submission(s): 829 Special Judge Problem Description When wake

ACM之路 455

HDU 4035 Maze (概率DP)

/* lxhgww被困在迷宫里,迷宫是一棵n顶点的树,lxhgww初始在点1。每个点三种可能 1.被杀,回到起点1(概率为k[i]) 2.逃脱,即逃出迷宫(概率为e[i]) 3.随机的走一条与改点相连的边(包括它与它父亲相连的那条边 求逃出迷宫期望的步数。 设E[i]表示在结点i时期望的步数, fi表示点i的父亲, m表示点i的度数,j表示i的子节点 当i为叶子

Interstellar_的博客 438

HDU 4035 Maze (概率dp)

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1917    Accepted Submission(s): 748 Special Judge Problem Description When wake up,

左眼皮跳跳 623

HDU 4035 Maze 概率dp

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1858    Accepted Submission(s): 730 Special Judge Problem Description When wake up,

Aosaki 514

HDU 4035 Maze (概率DP & 期望)

Maze Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 1055    Accepted Submission(s): 347Special Judge Problem Description When wake up, lxhgw...

weixin_34249678的博客 98
上一篇: HDU 4089 Activation [有环的概率DP]
下一篇: HDU 3853 LOOPS [简单概率DP]
GrassTreeFlower
博客等级 码龄11年 14粉丝 116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值