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. 使用Spring Cloud需要了解一些概念

    Spring Cloud是一个基于Spring Boot实现的微服务架构开发工具,它为基于JVM的微服务开发中的配置管理.服务发现.断路器.智能路由.微代理.控制总线.全局锁.决策竞选.分布式会话和集 ...

  2. 【OS_Linux】三大文本处理工具之sed命令

    1.sed命令的简介及用法 sed:即为流编辑器,“stream editor”的缩写.他先将源文件读取到临时缓存区(也叫模式空间)中,再对满足匹配条件的各行执行sed命令.sed命令只针对缓存区中的 ...

  3. 八:SQL之DQL数据查询语言单表操作

    前言: DQL数据库查询语言是我们在开发中最常使用的SQL,这一章总结了单表操作部分的常用查询方式 主要操作有:查询所有字段.查询指定字段.查询指定记录.带IN的关键字查询,范围查询,陪查询.查询空值 ...

  4. python 中requests 模块用py2exe生成exe后SSL certificate exception的问题

    [('system library', 'fopen', 'No such process'), ('BIO routines', 'BIO_new_file', 'no such file'), ( ...

  5. 项目之socket

    客户端socket 客户端套接字完成的任务很统一,发送请求,接收请求结果 可以封装成一个方法 使用的tcp协议存在粘包问题,故需要自定义报头 import json import struct #项目 ...

  6. (原)pat1007素数猜想

    ---恢复内容开始--- 1007. 素数对猜想 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们 ...

  7. PAT Basic 1039

    1039 到底买不买 小红想买些珠子做一串自己喜欢的珠串.卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖.于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么 ...

  8. PowerShell-第2章 管道

    2.1 过滤列表项或命令输出项 列出所有正在运行进程名称中包含"search"的进程,对进程名字属性使用-like操作符来比较进程的Name属性 Get-Process | Whe ...

  9. 解决手机助手与 android sdk 的adb 冲突问题

    现象:手机助手与 sdk 内的 adb冲突,用助手与真机连接后,sdk adb 就被干掉了 突发奇想: 突然有一天想到用助手的adb来覆盖sdk内的adb,果然奏效.现在eclipse.助手.cmd窗 ...

  10. swift final关键字、?、!可选与非可选符

    ?符号: 可选型 在初始化时可以赋值为nil !符号:  隐形可选型 类型值不能为nil,如果解包后的可选类型为nil会报运行时错误,主要用在一个变量/常量在定义瞬间完成之后值一定会存在的情况.这主要 ...