博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
D. Ilya and Escalator
阅读量:6942 次
发布时间:2019-06-27

本文共 2402 字,大约阅读时间需要 8 分钟。

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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.

Input

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.

Output

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.

Sample test(s)
Input
1 0.50 1
Output
0.5
Input
1 0.50 4
Output
0.9375
Input
4 0.20 2
Output
0.4

题目抽象:n个人排队上电梯,排头每秒上去的概率为p,一共t秒,求t秒都电梯内人数的期望。

思路:简单的概率dp,dp[i][j]表示第i秒电梯上有j个人的概率,最后累计一下期望

 

 

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 using namespace std;15 const int INF=0x7fffffff;16 const double EXP=1e-8;17 const int MS=2005;18 const int mod=100000007;19 typedef long long LL;20 double dp[MS][MS]; 21 // dp[i][j] 在i second 的时间内 进入 了j个人的概率, 22 23 /// dp[i-1][n-1]*p 24 // dp[i][n] 25 // dp[i-1][n]*1; 26 27 int main()28 {29 30 int n,t,i,j;31 double p,ans=0;32 memset(dp,0,sizeof(dp));33 dp[0][0]=1.0;34 cin>>n>>p>>t;35 for(i=0;i

 

转载于:https://www.cnblogs.com/767355675hutaishi/p/4299548.html

你可能感兴趣的文章
精读《React 的多态性》
查看>>
JQuery实现注册表单验证
查看>>
solr7安装(1)
查看>>
我为NET狂~群福利:逆天书库
查看>>
UNIX文件I/O
查看>>
说说React组件的State
查看>>
央视会玩,2017年春晚或推出VR直播
查看>>
c#扩展方法的使用
查看>>
Xamarin android 调用Web Api(ListView使用远程数据)
查看>>
always on 集群
查看>>
CentOS下LAMP一键yum安装脚本
查看>>
[20180403]关于时区问题.txt
查看>>
满足各种需求,德阳人民医院Wi-Fi覆盖选择飞鱼星
查看>>
疯狂剁手之后 平台帮了谁又肥了谁?
查看>>
8 个必备的PHP功能开发
查看>>
纳德拉:云计算是重要增长点18年目标200亿
查看>>
聚焦“微服务与容器云” 2017CIO时代线下CIO沙龙顺利举行
查看>>
入行数据科学,仅需6步
查看>>
Linux虚拟化技术KVM、QEMU与libvirt的关系(转)
查看>>
特斯联科技携手比特大陆共建国内首家物联网区块链实验室
查看>>