poj 3744 Scout YYF I(递推求期望)】的更多相关文章

poj 3744 Scout YYF I(递推求期望) 题链 题意:给出n个坑,一个人可能以p的概率一步一步地走,或者以1-p的概率跳过前面一步,问这个人安全通过的概率 解法: 递推式: 对于每个坑,我们可以这么定义一个数组: d[i]代表它安全落在位置i的概率,在这个1到max(a[i])的范围中,只有那些坑是不安全的,答案只需求出所有不掉入坑的概率的连乘即可 矩阵: 由于数字范围巨大,需要对递推式进行矩阵连乘加速 | p 1-p | | d[i] | | d[i+1] | | 1 0 | *…
题目链接: http://poj.org/problem?id=3744 Scout YYF I Time Limit: 1000MSMemory Limit: 65536K 问题描述 YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties, YYF is now at…
Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5020   Accepted: 1355 Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties,…
http://poj.org/problem?id=3744 题意: 现在有个屌丝要穿越一个雷区,雷分布在一条直线上,但是分布的范围很大,现在这个屌丝从1出发,p的概率往前走1步,1-p的概率往前走2步,求最后顺利通过雷区的概率. 思路: 首先很容易能得到一个递推式:$dp[i]=p*dp[i-1]+(1-p)*dp[i-2]$.但是直接递推肯定不行,然后我们发现这个很容易构造出矩阵来,但是这样还是太慢. 接下来讲一下如何优化,对于第i个雷,它的坐标为x[i],那么那顺利通过它的话,只能在x[i…
题目链接:http://poj.org/problem?id=3744 题意: 有n个地雷,位置为pos[i]. 在每个位置,你向前走一步的概率为p,向前走两步的概率为1-p. 你的初始位置为1. 问你通过雷区的概率. 题解: 表示状态: dp[i] = probability moving to i 表示走到i的概率 找出答案: ans = dp[last_mine+1] last_mine:最右边一颗雷的位置 如何转移: dp[i] = dp[i-1] * p + dp[i-2] * (1-…
分段的概率DP+矩阵快速幂                        Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4180   Accepted: 1076 Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. Af…
题意: 一条路上,给出n地雷的位置,人起始位置在1,向前走一步的概率p,走两步的概率1-p,踩到地雷就死了,求安全通过这条路的概率. 分析: 如果不考虑地雷的情况,dp[i],表示到达i位置的概率,dp[i]=dp[i-1]*p+dp[i-2]*(1-p),要想不踩地雷求出到达地雷位置的概率tmp,1-tmp就是不踩地雷的情况,问题又来了,位置最大是10^9,普通递推超时,想到了用矩阵优化. #include <map> #include <set> #include <li…
F - Scout YYF I Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series d…
Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 3523   Accepted: 1740 Case Time Limit: 2000MS   Special Judge Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material s…
Description YYF -p. Here is the task, given the place of each mine, please calculate the probality that YYF can go through the "mine road" safely. Input The input contains many test cases ended with EOF. Each test case contains two lines. The Fi…