CF518D.Ilya and Escalator
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
伊利亚厌倦了程序设计竞赛,离开了大学,在地铁公司找到了一份工作。他被委派了一项任务:计算自动扶梯的负载系数。
假设队列中有 n 个人等待乘坐自动扶梯。每一秒内,以下两种情况之一会发生:
- 队首的人以概率 p 进入自动扶梯;
- 或者队首的人因对自动扶梯感到恐惧而僵在原地,以概率 (1−p) 不移动,导致整个队列在其身后等待。
形式化地说,队列中第 i 个人只有在编号为 1 到 i−1(含)的所有人全部进入自动扶梯之后,才能进入自动扶梯。每一秒最多只有一人可以进入自动扶梯。自动扶梯是无限长的,因此一旦某人进入自动扶梯,他将永远停留在上面——即在之后的任意时刻,他都站在自动扶梯上。伊利亚需要计算:经过 t 秒后,站在自动扶梯上的人数的期望值。
你的任务是帮助他解决这一复杂问题。
输入格式
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.
输入的第一行包含三个数 n、p、t(1≤n,t≤2000,0≤p≤1)。其中 n 和 t 为整数,p 为实数,且小数点后恰好保留两位。
输出格式
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.
输出一个实数——t 秒后站在自动扶梯上的人数的期望值。绝对或相对误差不得超过 10−6。
输入输出样例
输入#1
1 0.50 1
输出#1
0.5
输入#2
1 0.50 4
输出#2
0.9375
输入#3
4 0.20 2
输出#3
0.4
输入解题思路,AI测评打分。不知道怎么写?