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 ...
随机推荐
- Linux设备驱动程序学习 高级字符驱动程序操作[阻塞型I/O和非阻塞I/O]【转】
转自:http://blog.csdn.net/jacobywu/article/details/7475432 阻塞型I/O和非阻塞I/O 阻塞:休眠 非阻塞:异步通知 一 休眠 安全地进入休眠的两 ...
- python几种装饰器的用法
用函数装饰函数 这种比较常见首先定义装饰器函数 def cache(func): data = {} @wraps(func) def wrapper(*args, **kwargs): key = ...
- 九、springboot整合redis二之缓冲配置
1.创建Cache配置类 @Configuration @EnableCaching public class RedisCacheConfig extends CachingConfigurerSu ...
- spring 学习之二 AOP编程
AOP概念 AOP, aspect oriented programing,翻译过来就是面向切面编程的意思,那什么叫面向切面编程呢?相对于之前传统的纵向继承方式来对原有功能进行功能扩展, 面向切面编程 ...
- java 判断字符串是否相等
判断字符串相等我们经常习惯性的写上if(str1==str2),这种写法在Java中可能会带来问题. java中判断字符串是否相等有两种方法: 1.用“==”运算符,该运算符表示指向字符串的引用是否相 ...
- Python学习笔记:startswith & endswith 判断开头结尾是否为指定字符串
作用: 判断字符串是否以指定字符或子字符串结尾,常用于判断文件类型. 如果以指定后缀结尾返回True,否则返回False. 可选参数"start"与"end"为 ...
- 10月15日 | 云栖大会“淘宝移动技术实践&开放论坛”来了!
参会报名链接:http://baichuan.taobao.com/marketing/yunqi#?baichuan_channel=cnblogs 顺应移动互联网消费升级趋势, 淘宝作为移动领域的 ...
- Java关于数组操作函数
数组排序及元素查找 sort()方法对Java数组进行排序. binarySearch() 方法来查找数组中的元素,返回该元素所在的位置. import java.util.*; public cla ...
- C# POS 小票打印
网上查了好多资料终于让我捣鼓出来了! public partial class Models_JXC_Sale_actNewSalePage : WebPartBase { public string ...
- C#基础之数据类型
c#有15个预定义类型,其中13个是值类型,两个是引用类型(string 和 object) 1.整型 2.浮点类型 float数据类型用于较小的浮点数,因为它要求的精度较低. double数据类型比 ...