●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 ...
随机推荐
- Java Client/Server 基础知识
Java的网络类库支持多种Internet协议,包括Telnet, FTP 和HTTP (WWW),与此相对应的Java网络类库的子类库为: Java.net Java.net.ftp Java. ...
- 获取android项目的数据库地址或者数据库名
你不需要知道该路径.只是使用数据库,你可以将它们删除的列表. for (String databaseName : context.databaseList()) { context.deleteDa ...
- java截取一个字符串正数或倒数某个特定字符前后的内容
取出正数第二个“.”后面的内容 public class TestCode { public static void main(String[] args) { String str ="2 ...
- hexo博客图片问题
hexo博客图片问题 第一步 首先确认_config.yml 中有 post_asset_folder:true. Hexo 提供了一种更方便管理 Asset 的设定:post_asset_folde ...
- Spring+Hibernate+Struts(SSH)框架整合
SSH框架整合 前言:有人说,现在还是流行主流框架,SSM都出来很久了,更不要说SSH.我不以为然.现在许多公司所用的老项目还是ssh,如果改成流行框架,需要成本.比如金融IT这一块,数据库dao层还 ...
- Linq 大合集
static void Main(string[] args) { string[] words = { "zero", "one", "two&qu ...
- 新概念英语(1-139)Is that you, John?
Lesson 139 Is that you, John? 是你吗,约翰? Listen to the tape then answer this question. Which John Smith ...
- hadoop2.6.0实践:004 启动伪分布式hadoop的进程
[hadoop@LexiaofeiMaster hadoop-2.6.0]$ start-dfs.shStarting namenodes on [localhost]localhost: start ...
- 云计算(2)it 是什么
2015年,全世界在it上面的花费达到3亿8千亿美金之多. 云数据中心:核心基础架构,云计算的物理载体,提供数据处理.存储和高性能计算支撑,包括服务器.存储.冷却.机房空间和能耗管理等. 超大规模的云 ...
- 用UIWebView加载本地图片和gif图
加载gif图: NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@" ...