题意:Michael has a telecontrol robot. One day he put the robot on a loop with n cells. The cells are numbered from 1 to n clockwise.

At
first the robot is in cell 1. Then Michael uses a remote control to
send m commands to the robot. A command will make the robot walk some
distance. Unfortunately the direction part on the remote control is
broken, so for every command the robot will chose a direction(clockwise
or anticlockwise) randomly with equal possibility, and then walk w cells
forward.
Michael wants to know the possibility of the robot stopping in the cell that cell number >= l and <= r after m commands.

链接:点我

时间上卡的有点紧

 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt;
double dp[][MAXN];
int a[MAXN];
int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
int x,l,r;
while(scanf("%d%d%d%d",&n,&m,&l,&r)!=EOF)
{
if(n==&&m==&&l==&&r==)break;
dp[][]=;
for(i=;i<=n;i++) dp[][i]=;
int now=;
while(m--)
{
scanf("%d",&x);
for(i=;i<n;i++)
{
dp[now^][i]=;
}
for(i=;i<n;i++)
{
if(dp[now][i]==) continue;
dp[now^][((i-x)%n+n)%n]+=0.5*dp[now][i];
dp[now^][(i+x)%n]+=0.5*dp[now][i];
}
now^=;
}
double ans=;
for(i=l-;i<r;i++)
{
ans+=dp[now][i];
}
printf("%.4lf\n",ans);
}
}

hdu 4576 概率dp **的更多相关文章

  1. hdu 4576(概率dp+滚动数组)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4576 思路:由于每次从某一位置到达另一位置的概率为0.5,因此我们用dp[i][j]表示第i次操作落在 ...

  2. HDU 4599 概率DP

    先推出F(n)的公式: 设dp[i]为已经投出连续i个相同的点数平均还要都多少次才能到达目标状态. 则有递推式dp[i] = 1/6*(1+dp[i+1]) + 5/6*(1+dp[1]).考虑当前这 ...

  3. HDU 5001 概率DP || 记忆化搜索

    2014 ACM/ICPC Asia Regional Anshan Online 给N个点,M条边组成的图,每一步能够从一个点走到相邻任一点,概率同样,问D步后没走到过每一个点的概率 概率DP  測 ...

  4. hdu 3853 概率dp

    题意:在一个R*C的迷宫里,一个人在最左上角,出口在右下角,在每个格子上,该人有几率向下,向右或者不动,求到出口的期望 现在对概率dp有了更清楚的认识了 设dp[i][j]表示(i,j)到(R,C)需 ...

  5. HDU 4815 概率dp,背包

    Little Tiger vs. Deep Monkey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K ( ...

  6. hdu 4050(概率dp)

    算是挺简单的一道概率dp了,如果做了前面的聪聪于可可的话,这题不需要什么预处理,直接概率dp就行了... #include <stdio.h> #include <stdlib.h& ...

  7. HDU 4405 (概率DP)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4405 题目大意:飞行棋.如果格子不是飞行点,扔骰子前进.否则直接飞到目标点.每个格子是唯一的飞行起点 ...

  8. hdu 4336 概率dp + 状压

    hdu 4336 小吃包装袋里面有随机赠送一些有趣的卡片,如今你想收集齐 N 张卡片.每张卡片在食品包装袋里出现的概率是p[i] ( Σp[i] <= 1 ), 问你收集全部卡片所需购买的食品数 ...

  9. hdu 5001 概率DP 图上的DP

    http://acm.hdu.edu.cn/showproblem.php?pid=5001 当时一看是图上的就跪了 不敢写,也没退出来DP方程 感觉区域赛的题  一则有一个点难以想到 二则就是编码有 ...

随机推荐

  1. js ajax 向后台传递数组

    //定义数组 var _arrays = []; for (var i = 0; i < 10; i++) { _arrays.push(i); } //post $.post(href, {l ...

  2. SVN服务器搭建--Subversio与TortoiseSVN的配置安装

    SVN服务器搭建和使用(一) Subversion是优秀的版本控制工具,其具体的的优点和详细介绍,这里就不再多说. 首先来下载和搭建SVN服务器. 现在Subversion已经迁移到apache网站上 ...

  3. [bug]使用SharpZipLib遇到中文名称乱码问题

    写在前面 业务逻辑是这样的,需要导出一个app的话题,并需要把该话题下帖子的附件导出,然后需求想修改成人员的名称.jpg的格式.所以就出现了中文乱码的问题.在本地没问题,但发布到服务器上面就出问题,每 ...

  4. cf.295.C.DNA Alignment(数学推导)

    DNA Alignment time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  5. E. Tetrahedron(数学推导)

    E. Tetrahedron 分类: AC路漫漫2013-08-08 16:07 465人阅读 评论(0) 收藏 举报 time limit per test 2 seconds memory lim ...

  6. Windows下tcp参数优化

    Windows系统下的TCP参数优化2013-04-25      0 个评论       作者:最初的幸福ever收藏     我要投稿Windows系统下的TCP参数优化 TCP连接的状态与关闭方 ...

  7. Linux下更好用的帮助命令—cheat

    导读 Linux系统中,我们经常会用man命令来帮助查看这个命令的具体用法,man是很强大的,但是英语不好的同学用man用起来可能不那么顺手,自然而然的就出现了cheat命令,cheat命令就是通过简 ...

  8. Awvs如何扫描需要登录的部分

    一个小技巧,可能部分的人习惯了按下一步.所以不大知道.给大家说说哈. 到LOGIN步骤的时候,在Login sequen 新建.然后你懂的了.会新出来一个浏览器,直接登录后一直下一步即可

  9. [官方教程] [ES4封装教程]1.使用 VMware Player 创建适合封装的虚拟机

    [转载处,http://bbs.itiankong.com/] 前言: 首先要明确的一点,系统封装操作的源计算机一般为虚拟计算机(简称虚拟机.VM等),这也是为什么我们要在封装教程的第一章就专门学习虚 ...

  10. 基础知识《二》java的基本类型

    一.java基本数据类型 Java基本类型共有八种,基本类型可以分为三类,字符类型char,布尔类型boolean以及数值类型byte.short.int.long.float.double.数值类型 ...