●CodeForces 518D Ilya and Escalator
题链:
http://codeforces.com/problemset/problem/518/D
题解:
期望dp。
定义dp[t][i]表示在第t秒开始之前,已经有了i个人在电梯上,之后期望能有多少人上电梯。
转移:
dp[t][i]=(1-P)*dp[t+1][i]+P*(dp[t+1][i+1]+1)
代码:
#include<bits/stdc++.h>
#define MAXN 2005
using namespace std;
int N,T;
double P,dp[MAXN][MAXN];
int main(){
ios::sync_with_stdio(0);
cin>>N>>P>>T;
for(int t=T;t>=1;t--)
for(int i=0;i<N;i++)
dp[t][i]=(1-P)*dp[t+1][i]+P*(dp[t+1][i+1]+1);
cout<<fixed<<setprecision(6)<<dp[1][0]<<endl;
return 0;
}
●CodeForces 518D Ilya and Escalator的更多相关文章
- Codeforces 518D Ilya and Escalator
http://codeforces.com/problemset/problem/518/D 题意:n个人,每秒有p的概率进电梯,求t秒后电梯里人数的期望 考虑dp:f[i][j]代表第i秒有j个人的 ...
- CoderForces 518D Ilya and Escalator (期望DP)
题意:给定 n 个人,在每一时刻一个人进入地铁的概率是 p,站着不动的概率是 1-p,然后问你 t 时间地铁里有多少人. 析:很明显这是一个期望DP,用d[i][j]表示 i 时刻 j 个人进入地铁的 ...
- 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 ...
- D. Ilya and Escalator
D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- CF518D. Ilya and Escalator [概率DP]
CF518D. Ilya and Escalator 题意:n个人,每秒p的概念队首的人进入电梯,求t秒后期望人数 直接使用期望定义 \(f[i][j]\) i秒后电梯中j个人的概率 注意n个人的时候 ...
- Codeforces 518 D Ilya and Escalator
Discription Ilya got tired of sports programming, left university and got a job in the subway. He wa ...
- CodeForces 313C Ilya and Matrix
Ilya and Matrix Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Su ...
- 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 ...
- codeforces 842C Ilya And The Tree
Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very ...
随机推荐
- 第二周作业(pta存在的问题)
***第一题 错题截图 错因分析:中英文符号用混 改正截图: 思路分析:(1)由输入格式可知,该程序需要用到scanf函数 (2)构建框架 (3)根据要求打入代码 **第二题(正确) 代码截图: 思路 ...
- 201621123057 《Java程序设计》第4周学习总结
1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 答: (普通方法 / 构造函数)重载. static . final.继承与多态.extends.object类.abstrac ...
- iOS开发-OC分支结构
BOOL类型 返回值:真:YES 假:NO BOOL数据类型占一个字节的内存空间,占位符为%d. 计算机在识别时,YES就替换成1,NO就替换成0. bool是C语言中的布尔类型,返回值为true ...
- android 框架LoonAndroid,码农偷懒专用
介绍 http://www.eoeandroid.com/thread-324764-1-1.html 架构培训视频: http://pan.baidu.com/s/1mgv8HTm 简介:下载 ht ...
- http post/get 2种使用方式
public class HttpUtil { //HttpPost public static String executePost(String url, List<NameValue ...
- 关于webService发布的wsdl中的import问题解决
大家都知道jdk1.6及以后都支持了对webService的原生态的支持:它在发布时会生成一个wsdl和一个xsd(一个类只生成一个xsd)所以就保留了引用关系,如下: <?xml versio ...
- Something about SeekingJob---Resume简历
这几天脑子里满满的装的都是offer.offer.offer快到碗里来,但是offer始终不是巧克力,并没那么甜美可口易消化. 找工作刚开始,就遇到了不小的阻力,看到Boss直聘上各种与IT相关的工作 ...
- linux下面的智能解压脚本smart解压
file命令可以辨别出一个给定文件的文件类型,如:file lf.gz,其输出结果为: lf.gz: gzip compressed data, deflated, original filename ...
- lamp环境搭建经验总结
环境:centos6.4,13个源码包:参考教程高罗峰细说php思路:1.首先确定gcc,g++的安装,因为这是c语言的编译工具,没有它,源码不可能安装,redhat的yum需要配置,分为本地源和网络 ...
- 关于python爬虫经常要用到的一些Re.正则表达式
转载:https://blog.csdn.net/skyeyesxy/article/details/50837984 1.正则表达式的常用符号与方法 常用符号:点号,星号,问号与括号(小括号) (. ...