poj3744 Scout YYF I】的更多相关文章

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 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: 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,…
题意:n个地雷(n<=10)在长度10^8的坐标轴上,yyf从横坐标为1的点开始,每一步有p的概率向右跳一格,(1-p)的概率向右跳两格(不会踩到中间一格),如果踩到地雷他就会死.问活下来的概率.(其实我们的yyf小朋友是被派去滚雷?) 首先考虑一个暴力的DP.记f[i]为活着经过横坐标为i的点的概率, 如果点i处无地雷则f[i]=f[i-1]*p+f[i-2]*(1-p) 如果点i处有地雷则f[i]=0 由此我们知道,如果yyf能活下来,他一定会经过最后一个地雷右边一格的位置t,所以我们要求的…
传送门: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…
题目链接: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…
http://poj.org/problem?id=3744 题意:一条路,起点为1,有概率p走一步,概率1-p跳过一格(不走中间格的走两步),有n个点不能走,问到达终点(即最后一个坏点后)不踩坏点的概率为多少.坏点的坐标范围 [1,100000000]   概率dp的算是入门题…其实写起来和以前的矩阵似乎并没有什么区别呢…状态其实还挺好想的. 坏点sort一下:然后把每一个坏点后一格走到一个坏点前一格的概率乘到答案上,再乘一个1-p跳到坏点后,循环即可.   代码 #include<cstdi…
分段的概率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…
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,…