Discription

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.

Examples

Input
1 0.50 1
Output
0.5
Input
1 0.50 4
Output
0.9375
Input
4 0.20 2
Output
0.4

    设f[i][j]为过了T秒后电梯上有j个人的概率,直接转移就行了
#include<bits/stdc++.h>
#define ll long long
#define D double
using namespace std;
const int maxn=2005;
D P,ans=0,f[maxn][maxn];
int N,T; inline void dp(){
f[0][0]=1;
for(int i=0;i<T;i++){
for(int j=0;j<N;j++) if(f[i][j]>0){
f[i+1][j+1]+=f[i][j]*P;
f[i+1][j]+=f[i][j]*(1-P);
}
f[i+1][N]+=f[i][N];
}
} inline void calc(){
for(int i=1;i<=N;i++) ans+=f[T][i]*i;
} int main(){
cin>>N>>P>>T;
dp(),calc();
printf("%.11lf\n",ans);
return 0;
}

  

 

Codeforces 518 D Ilya and Escalator的更多相关文章

  1. CF 518 D. Ilya and Escalator

    Ilya got tired of sports programming, left university and got a job in the subway. He was given the ...

  2. Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP

    D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. D. Ilya and Escalator

    D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. CF518D. Ilya and Escalator [概率DP]

    CF518D. Ilya and Escalator 题意:n个人,每秒p的概念队首的人进入电梯,求t秒后期望人数 直接使用期望定义 \(f[i][j]\) i秒后电梯中j个人的概率 注意n个人的时候 ...

  5. Codeforces 518D Ilya and Escalator

    http://codeforces.com/problemset/problem/518/D 题意:n个人,每秒有p的概率进电梯,求t秒后电梯里人数的期望 考虑dp:f[i][j]代表第i秒有j个人的 ...

  6. ●CodeForces 518D Ilya and Escalator

    题链: http://codeforces.com/problemset/problem/518/D题解: 期望dp. 定义dp[t][i]表示在第t秒开始之前,已经有了i个人在电梯上,之后期望能有多 ...

  7. 【55.70%】【codeforces 557A】Ilya and Diplomas

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【codeforces 754B】 Ilya and tic-tac-toe game

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. codeforces#518 Div2 ABCDE

    A---Birthday http://codeforces.com/contest/1068/problem/A 题意: 有n种硬币,m个人.m个人要给Ivan送硬币,每个人送的硬币都要互不相同但数 ...

随机推荐

  1. asp.net core vs2017运行控制台应用程序一闪而过没执行

    在cmd中执行dotnet run,会提示当前应用程序版本高于当前安装的.net core sdk 版本 解决: 升级.net core版本到最新

  2. Lucene入门基础教程

    http://www.linuxidc.com/Linux/2014-06/102856.htm

  3. iOS UIView中的坐标转换convertPoint --- iOS开发系列 ---项目中成长的知识六

    如果你的UITableViewCell里面有一个Button需要响应事件,你会怎么做? 在Controller中使用 button父类的父类?   例如:UITableViewCell *parent ...

  4. 697. Degree of an Array@python

    Given a non-empty array of non-negative integers nums, the degree of this array is defined as the ma ...

  5. PAT 乙级 1008

    题目 题目地址:PAT 乙级 1008 思路 本题需要注意的一点是当 m > n 的时候会出现逻辑性的错误,需要在 m > n 情况下对m做模运算,即 m % n 代码 #include ...

  6. 初涉期望dp/概率dp【在更】

    大致可以分为两种:爆精度:小数取模.

  7. Python中如何将数据存储为json格式的文件

    一.基于json模块的存储.读取数据 names_writer.py import json names = ['joker','joe','nacy','timi'] filename='names ...

  8. Python全栈工程师之html学习笔记

    https://www.bilibili.com/video/av15241731 笔记来源:黑马程序员 HTML(Hyper Text Markup Language):超文本标签语言 HTML标签 ...

  9. LeetCode(150) Evaluate Reverse Polish Notation

    题目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, ...

  10. python中join()函数讲解

    本文简述的是string.join(words[, sep]),它的功能是把字符串或者列表,元组等的元素给连接起来,返回一个字符串,和split()函数与正好相反,看下面的代码理解. a=[" ...