博客
关于我
【Lintcode】266. Expect Distance
阅读量:214 次
发布时间:2019-02-28

本文共 304 字,大约阅读时间需要 1 分钟。

从山洞A出发,有两条路。一条路走x千米,回到A;另一条路走2千米,到达B。从B出发,也有两条路。一条路走y千米,回到A;另一条路走z千米,到达出口C。我们需要计算从A出发走出C的期望路程。

设E[X]为从A出发走出C的期望路程,E[Y]为从B出发走出C的期望路程。根据条件期望公式,可以建立以下方程:

  • 从A出发:E[X] = 1/2 (x + E[X]) + 1/2 (2 + E[Y])

  • 从B出发:E[Y] = 1/2 (y + E[X]) + 1/2 z

  • 通过解这两个方程,可以得到:

    E[X] = 2x + y + z + 4

    因此,从山洞A出发走出C的期望路程为:

    2x + y + z + 4 千米

    转载地址:http://txcs.baihongyu.com/

    你可能感兴趣的文章
    NOPI读取Excel
    查看>>
    NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>
    npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
    查看>>
    npm切换到淘宝源
    查看>>
    npm前端包管理工具简介---npm工作笔记001
    查看>>
    npm和yarn清理缓存命令
    查看>>
    npm和yarn的使用对比
    查看>>
    npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
    查看>>
    npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
    查看>>
    NPOI之Excel——合并单元格、设置样式、输入公式
    查看>>
    NPOI利用多任务模式分批写入多个Excel
    查看>>
    NR,NF,FNR
    查看>>
    nrf开发笔记一开发软件
    查看>>
    NSDateFormatter的替代方法
    查看>>
    nsis 安装脚本示例(转)
    查看>>
    NSOperation基本操作
    查看>>
    NSSet集合 无序的 不能重复的
    查看>>
    NT AUTHORITY\NETWORK SERVICE 权限问题
    查看>>
    NT symbols are incorrect, please fix symbols
    查看>>