Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP
2 seconds
256 megabytes
standard input
standard output
Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine the escalator load factor.
Let's assume that n people stand in the queue for the escalator. At each second one of the two following possibilities takes place: either the first person in the queue enters the escalator with probability p, or the first person in the queue doesn't move with probability (1 - p), paralyzed by his fear of escalators and making the whole queue wait behind him.
Formally speaking, the i-th person in the queue cannot enter the escalator until people with indices from 1 to i - 1 inclusive enter it. In one second only one person can enter the escalator. The escalator is infinite, so if a person enters it, he never leaves it, that is he will be standing on the escalator at any following second. Ilya needs to count the expected value of the number of people standing on the escalator after t seconds.
Your task is to help him solve this complicated task.
The first line of the input contains three numbers n, p, t (1 ≤ n, t ≤ 2000, 0 ≤ p ≤ 1). Numbers n and t are integers, number p is real, given with exactly two digits after the decimal point.
Print a single real number — the expected number of people who will be standing on the escalator after t seconds. The absolute or relative error mustn't exceed 10 - 6.
1 0.50 1
0.5
1 0.50 4
0.9375
4 0.20 2
0.4
题意:给你一个队列,然后每个时刻,有P的概率会离开一个人,然后问你在t时刻,离开人的期望是多少
题解:dp[i][j]表示第i时刻有j个人离开
转移方程:dp[i][j]=(1-p)*dp[i-1][j]+p*dp[i-1][j-1]
double dp[maxn][maxn];//表示第i秒有j个人离开
int main()
{
memset(dp,,sizeof(dp));
int n,t;
double p;
cin>>n>>p>>t;
dp[][]=;
for(int i=;i<=t;i++)
{
dp[i][]=(-p)*dp[i-][];
for(int j=;j<n;j++)
{
dp[i][j]=p*dp[i-][j-]+(-p)*dp[i-][j];
}
dp[i][n]=p*dp[i-][n-]+dp[i-][n];
}
double ans=;
for(int i=;i<=n;i++)
{
ans+=i*dp[t][i];
}
printf("%.6f\n",ans);
}
Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP的更多相关文章
- Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP
D. Bad Luck Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/pr ...
- Codeforces Round #105 (Div. 2) D. Bag of mice 概率dp
题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemo ...
- Codeforces Round #284 (Div. 2) D. Name That Tune [概率dp]
D. Name That Tune time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #233 (Div. 2)D. Painting The Wall 概率DP
D. Painting The Wall ...
- Codeforces Round #597 (Div. 2) E. Hyakugoku and Ladders 概率dp
E. Hyakugoku and Ladders Hyakugoku has just retired from being the resident deity of the South Black ...
- Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心
Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...
- 递推 Codeforces Round #186 (Div. 2) B. Ilya and Queries
题目传送门 /* 递推:用cnt记录前缀值,查询区间时,两个区间相减 */ #include <cstdio> #include <algorithm> #include &l ...
- Codeforces Round #267 (Div. 2) C. George and Job(DP)补题
Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently ...
随机推荐
- souce insight出错 There was an error opening project
souce insight出错 There was an error opening project: "...": Options->Preferences->Fol ...
- maven profile 优先级
maven profile是有优先级别 也就是说在setting.xml的profile优先级比pom中同名的profile高. 可以使用 mvn help:active-profiles 这个命令是 ...
- MySQL 修改数据
UPDATE 语句 修改或更新 MySQL 中的数据,我们可以使用 SQL UPDATE 命令来操作. 可以同时修改 一个 或 多个 字段: 可以在where子句中指定条件: 可以在一个单独表中更新数 ...
- centos7 部署 seafile
=============================================== 2018/5/13_第1次修改 ccb_warlock == ...
- Linux下配置Samba服务器全过程
Linux下配置Samba服务器全过程 user级别的samba的配置 http://www.linuxidc.com/Linux/2014-11/109234.htm http://www.linu ...
- python之assert断言
assert只是一个检查,为真不做任何事,不为真时,抛出异常,并包含错误信息 1.根据布尔值判断 2.判断是否相等 3.返回值是否为空 4.是否包含某值 x in y 其他方法,可以参考http:// ...
- JMeter接口&性能测试
JMeter接口测试 目前最新版本发展到5.0版本,需要Java7以上版本环境,下载解压目录后,进入\apache-jmeter-5.0\bin\,双击ApacheJMeter.jar文件启动JMem ...
- javaweb作业二
作业:1.书写servlet的类架构及重要方法.(ServletConfig,Servlet)<---GenericServlet(getInitParameter(String str);in ...
- springMVC源码分析--HttpMessageConverter参数read操作(二)
上一篇博客springMVC源码分析--HttpMessageConverter数据转化(一)中我们简单介绍了一下HttpMessageConverter接口提供的几个方法,主要有以下几个方法: (1 ...
- Linux学习笔记:mv移动或文件重命名
mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files),是Linux系统下常用的命令,经常用来备份文件或者目录. 语法:mv 源文件 目标文件 视mv命令中 ...