Scout YYF I 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 the start of enemy's famous "mine road". This is a very long road, on which…
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, YYF is now at the start of enemy's famous "mine road". This is a very long road, on which…
Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8598   Accepted: 2521 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,…
Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9552   Accepted: 2793 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-p跳过一格(不走中间格的走两步),有n个点不能走,问到达终点(即最后一个坏点后)不踩坏点的概率为多少.坏点的坐标范围 [1,100000000]   概率dp的算是入门题…其实写起来和以前的矩阵似乎并没有什么区别呢…状态其实还挺好想的. 坏点sort一下:然后把每一个坏点后一格走到一个坏点前一格的概率乘到答案上,再乘一个1-p跳到坏点后,循环即可.   代码 #include<cstdi…
题目链接:http://poj.org/problem?id=3744 简单的概率DP,分段处理,遇到mine特殊处理.f[i]=f[i-1]*p+f[i-2]*(1-p),i!=w+1,w为mine点.这个概率显然是收敛的,可以转化为(f[i]-f[i-1])/(f[i-1]-f[i-2])=p-1.题目要求精度为1e-7,在分段求的时候我们完全可以控制进度,精度超出了1e-7就不运算下去了.当然此题还可以用矩阵乘法来优化. 考虑概率收敛代码: //STATUS:C++_AC_0MS_164K…
题目大意:有n颗地雷分布在一条直线上,有个人的起始位置在1,他每次前进1步的概率为p,前进两步的概率为1-p,问他不碰到地雷的概率. 题目分析:定义状态dp(i)表示到了dp(i)的概率,则状态转移方程为dp(i)=p*dp(i-1)+(1-p)*dp(i-2).要想安全通过x(i)到达x(i)+1只能由x(i)-1走两步,所以,可以将整条直线分成n段,那么从x(i-1)+1安全通过第 i 颗地雷概率为1-p(到达x(i)).坐标之间的距离又很大,所以可以用矩阵二分幂优化. 代码如下: # in…
题目: 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, YYF is now at the start of enemy's famous "mine road". This is a very long road, on w…
题目链接 分析&&题意来自 : http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710586.html 题意: 在一条不满地雷的路上,你现在的起点在1处.在N个点处布有地雷,1<=N<=10.地雷点的坐标范围:[1,100000000]. 每次前进p的概率前进一步,1-p的概率前进1-p步.问顺利通过这条路的概率.就是不要走到有地雷的地方. 分析: 设dp[i]表示到达i点的概率,则 初始值 dp[1]=1. 很容易想到转…
传送门:http://poj.org/problem?id=3744 令f(i)表示到i,安全的概率.则f(i) = f(i - 1) * p + f(i - 2) * (1 - p),若i位置有地雷,则f(i) = 0.很显然,要用矩阵来加速,矩阵也很好构造,懒得写了,百度图片搜“poj3744”就能看到.注意一下边界的处理. #include <cstdio> #include <algorithm> #include <cstring> const int max…