HDU 4576 Robot (很水的概率题)
Robot
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)
Total Submission(s): 158 Accepted Submission(s): 46

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.
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.
1
5 2 4 4
1
2
0 0 0 0
0.2500
/* **********************************************
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 (很水的概率题)的更多相关文章
- HDU 4576 Robot(概率dp)
题目 /*********************复制来的大致题意********************** 有N个数字,M个操作, 区间L, R. 然后问经过M个操作后落在[L, R]的概率. * ...
- HDU 4576 Robot (概率DP)
暴力DP求解太卡时间了...........写挫一点就跪了 //hdu robot #include <cstdio> #include <iostream> #include ...
- HDU 4576 Robot (概率 & 期望)
Robot Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Sub ...
- HDU 4576 Robot(概率dp)
Robot Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Sub ...
- HDU - 4576 Robot(概率dp+滚动数组)
题意:所有的格子围成一个圈,标号为1~n,若从格子1出发,每次指令告知行走的步数,但可能逆时针也可能顺时针走,概率都是1/2,那么问走了m次指令后位于格子l~r(1≤l≤r≤n)的概率. 分析: 1. ...
- HDU 4593 Robot (水题)
题意:有 n 个数,其中有两个数中相同的,让你找出这个数. 析:太简单了么,只要用数组下标记一下这个数的数量即可. 代码如下: #include <iostream> #include & ...
- HDU 5985/nowcoder 207D - Lucky Coins - [概率题]
题目链接:https://www.nowcoder.com/acm/contest/207/D 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5985 ...
- HDU 2843 I Will Win(概率题?,怨念颇深,简单)
题目 真不想说什么,,,这神题真讨厌,,,多校的.. //又是一道神题... #include<stdio.h> #include<string.h> //最大公约数 int ...
- HDU 4576 Robot
思路 概率dp 既然是求概率,顺推 显然有转移\(dp[i][j]=dp[i-1][j-w]/2+dp[i-1][w]/2\) 然后是环,注意特判一下 环上不要用取模处理循环的情况,会被卡常 代码 # ...
随机推荐
- 大原則 研讀 spec 與 code 的 心得
最近在研究 stm32f429i-disc0 的 device tree source code, 並且 參造 Devicetree Specification Release 0.1, 在 dts ...
- XCopy复制文件夹命令及参数详解以及xcopy拷贝目录并排除特定文件
XCOPY是COPY的扩展,可以把指定的目录连文件和目录结构一并拷贝,但不能拷贝系统文件:使用时源盘符.源目标路径名.源文件名至少指定一个:选用/S时对源目录下及其子目录下的所有文件进行COPY.除非 ...
- SVN使用详解
一.SVN的使用 项目经理使用,写好项目框架.文档等. 李四(程序员)的使用,在项目经理写好的框架上进行开发. 二.SVN三大指令 Checkout(检出操作): 连接到svn服务器 更新服务器数据到 ...
- 并发容器ConcurrentHashMap与synchronized联合使用达到线程安全
http://blog.csdn.net/yansong_8686/article/details/50664338 map.put(KEY, map.get(KEY) + 1); 实际上并不是原子操 ...
- Guice2.0的变化——第一部分 新的特性(上)
http://superleo.iteye.com/blog/314816 Private Modules PrivateModules 用于创建并不需要对外可见的绑定对象.当然,这样会使得封装变得更 ...
- zoj 3195
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3320 离线算法RE了.. #include<stdio.h> #i ...
- Google的C++开源代码项
转:http://blog.csdn.net/wenrenhua08/article/details/40040903 v8 - V8 JavaScript EngineV8 是 Google 的 ...
- Linux 基础——开山篇
为什么要开始学习Linux命令? 首先当然是因为工作需要了,现在的工作是负责银行调度的系统的源系统接入的工作,经常要到生产部署版本.所以……买了一本<Linux命令行与shell脚本编程大全&g ...
- 一次cloudstack启动cloudstack-agent报错的处理过程
http://www.bubuko.com/infodetail-2397888.html
- 【JBPM4】任务form表单
主要是在任务节点处保存一个链接地址(表单),方便在执行到此时取值,访问. 好处是XML可随时修改,部署. JPDL <?xml version="1.0" encoding= ...