题意: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. linux+apache url大小写敏感问题

    Linux对文件目录大小写敏感,URL大小写敏感会导致网页打不开,解决方法之一是启用Apache的mod_speling.so模块. 1.确认/usr/lib/httpd/modules目录下是否存在 ...

  2. innerText在谷歌、火狐浏览器下的使用

    使用innerHTML.replace(/<.+?>/gim,'')代替innerText,简单正则替换一下

  3. 只能输入汉字js脚本

    <html> <head> <meta http-equiv="Content-Type" content="text/html" ...

  4. linux ls和 ll 命令

    工作中用到      ll -alrth|tail -30    命令 所以再来回顾一下 ls 命令 linux ls和 ll 命令 ll 命令列出的信息更加详细,有时间,是否可读写等信息 ll命令和 ...

  5. l来自wentao:项目加入缓存(redis),实时调试时用 -----可视化缓存,flushdb

    下文来自segmentfault,网站:一个交流网站:https://segmentfault.com/ 在做一个项目时如果加入缓存(例如redis),我如何进行实时调试呢? 缓存 高并发 架构 gz ...

  6. mysql字符串截取

    mysql字符串截取 update zcat ) where lev1 is null; update zcat ) where lev2 is null; 函数: 1.从左开始截取字符串 left( ...

  7. PHP初学者必须掌握的10个知识点

    这里总结了PHP初学者容易感到困惑的10个问题,供大家参考.1.页面之间无法传递变量get,post,session在最新的php版本中自动全局变量是关闭的,所以要从上一页面取得提交过来得变量要使用1 ...

  8. Android/iOS微信6.3.5同时发布更新 支持群视频聊天、群公告

    下午微信6.3.5发布更新,新版最大变化就是支持群视频聊天,又一次向手机QQ靠拢.在群管理方面,支持发布群公告,支持群主转让给其他群成员,同样都是QQ玩剩下的功能.另外,新版支持微信运动查看步数图表. ...

  9. Android EditText 文本框实现搜索和清空效果

    前言 本文实现的效果:文本框输入为空时显示输入的图标:不为空时显示清空的图标,此时点击清空图标能清空文本框内输入文字. 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnbl ...

  10. 图像特征提取:Sobel边缘检测

    前言 点和线是做图像分析时两个最重要的特征,而线条往往反映了物体的轮廓,对图像中边缘线的检测是图像分割与特征提取的基础.文章主要讨论两个实际工程中常用的边缘检测算法:Sobel边缘检测和Canny边缘 ...