Robot

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)
Total Submission(s): 158    Accepted Submission(s): 46

Problem Description
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.

 
Input
There are multiple test cases. 
Each test case contains several lines.
The first line contains four integers: above mentioned n(1≤n≤200) ,m(0≤m≤1,000,000),l,r(1≤l≤r≤n).
Then m lines follow, each representing a command. A command is a integer w(1≤w≤100) representing the cell length the robot will walk for this command.  
The input end with n=0,m=0,l=0,r=0. You should not process this test case.
 
Output
For each test case in the input, you should output a line with the expected possibility. Output should be round to 4 digits after decimal points.
 
Sample Input
3 1 1 2
1
5 2 4 4
1
2
0 0 0 0
 
Sample Output
0.5000
0.2500
 
Source
 
 
 
 
 
按照概率DP过去,比较暴力,T_T
 
 /* **********************************************
Author : kuangbin
Created Time: 2013/8/10 11:51:05
File Name : F:\2013ACM练习\比赛练习\2013杭州邀请赛重现\1001.cpp
*********************************************** */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
double dp[][];
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n,m,l,r;
while(scanf("%d%d%d%d",&n,&m,&l,&r) == )
{
if(n == && m == && l == && r == )break;
dp[][] = ;
for(int i = ;i < n;i++)dp[][i] = ;
int now = ;
while(m--)
{
int v;
scanf("%d",&v);
for(int i = ;i < n;i++)
dp[now^][i] = 0.5*dp[now][(i-v+n)%n] + 0.5*dp[now][(i+v)%n];
now ^= ;
}
double ans = ;
for(int i = l-;i < r;i++)
ans += dp[now][i];
printf("%.4lf\n",ans);
}
return ;
}
 

HDU 4576 Robot (很水的概率题)的更多相关文章

  1. HDU 4576 Robot(概率dp)

    题目 /*********************复制来的大致题意********************** 有N个数字,M个操作, 区间L, R. 然后问经过M个操作后落在[L, R]的概率. * ...

  2. HDU 4576 Robot (概率DP)

    暴力DP求解太卡时间了...........写挫一点就跪了 //hdu robot #include <cstdio> #include <iostream> #include ...

  3. HDU 4576 Robot (概率 & 期望)

    Robot Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Sub ...

  4. HDU 4576 Robot(概率dp)

    Robot Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Sub ...

  5. HDU - 4576 Robot(概率dp+滚动数组)

    题意:所有的格子围成一个圈,标号为1~n,若从格子1出发,每次指令告知行走的步数,但可能逆时针也可能顺时针走,概率都是1/2,那么问走了m次指令后位于格子l~r(1≤l≤r≤n)的概率. 分析: 1. ...

  6. HDU 4593 Robot (水题)

    题意:有 n 个数,其中有两个数中相同的,让你找出这个数. 析:太简单了么,只要用数组下标记一下这个数的数量即可. 代码如下: #include <iostream> #include & ...

  7. HDU 5985/nowcoder 207D - Lucky Coins - [概率题]

    题目链接:https://www.nowcoder.com/acm/contest/207/D 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5985 ...

  8. HDU 2843 I Will Win(概率题?,怨念颇深,简单)

    题目 真不想说什么,,,这神题真讨厌,,,多校的.. //又是一道神题... #include<stdio.h> #include<string.h> //最大公约数 int ...

  9. HDU 4576 Robot

    思路 概率dp 既然是求概率,顺推 显然有转移\(dp[i][j]=dp[i-1][j-w]/2+dp[i-1][w]/2\) 然后是环,注意特判一下 环上不要用取模处理循环的情况,会被卡常 代码 # ...

随机推荐

  1. smb windows中使用的文件共享协议(主要用于与windows互通)

    主要是samba服务. SMB协议又成为CIFS(Common Internet File System)协议 samba服务功能: 1文件共享 2打印共享 3加入windows2000/2003/2 ...

  2. selenium遇到的一些问题,持续更新

    1.今天早上运行程序的时候,发现我在循环点击一个元素的时候出现了错误 selenium.common.exceptions.StaleElementReferenceException: Messag ...

  3. python 使用国内源安装软件

    python linux 等 使用国内源安装软件 速度更快 你值得拥有 ! 豆瓣源:pip install -i https://pypi.douban.com/simple/ 阿里源:pip ins ...

  4. overflow属性在IE6下面失去效果

    自然状态下 overflow的属性设置,本来是超过了一定的长度时会自动产生滚动条,但是在ie6下面失效了. 例如:原来的代码: .code{overflow-x:auto;margin:5px aut ...

  5. Request对象与Response对象

    1.Request对象 Request对象是来获取请求消息的,是由服务器(Tomcat)创建的. Request对象继承体系结构: ServletRequest        --    接口     ...

  6. HDU-5360

    Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  7. win10网速慢

    升级到win10之后发现网速特别慢,搜了下,网上的解决办法果然好使,按照如下操作即可. 返回桌面,按WIN+R键组合,运行gpedit.msc 打开组策略 依次展开管理模板->网络->Qo ...

  8. Gas Station——又是一道经典问题

    There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You ...

  9. hdu5735

    很美妙的一题 官方题解 http://www.cnblogs.com/duoxiao/p/5777632.html 感觉有meet in middle的思想 #include<bits/stdc ...

  10. 微软企业库5.0 学习之路——第七步、Cryptographer加密模块简单分析、自定义加密接口及使用—下篇

    在上一篇文章中, 我介绍了企业库Cryptographer模块的一些重要类,同时介绍了企业库Cryptographer模块为我们提供的扩展接口,今天我就要根据这些 接口来进行扩展开发,实现2个加密解密 ...