题链:

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的更多相关文章

  1. Codeforces 518D Ilya and Escalator

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

  2. CoderForces 518D Ilya and Escalator (期望DP)

    题意:给定 n 个人,在每一时刻一个人进入地铁的概率是 p,站着不动的概率是 1-p,然后问你 t 时间地铁里有多少人. 析:很明显这是一个期望DP,用d[i][j]表示 i 时刻 j 个人进入地铁的 ...

  3. 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 ...

  4. D. Ilya and Escalator

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

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

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

  6. Codeforces 518 D Ilya and Escalator

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

  7. CodeForces 313C Ilya and Matrix

    Ilya and Matrix Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Su ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. C语言程序设计基础-第1周作业-初步

    1.安装带有计算机术语的翻译软件 2.在自己电脑上安装C编译器,windows系统建议安装dev-c++,其他系统自行查找. 3.加入课程小组,有任何疑问可以在小组中提问:https://group. ...

  2. Linux下I/O多路转接之epoll(绝对经典)

    epoll 关于Linux下I/O多路转接之epoll函数,什么返回值,什么参数,我不想再多的解释,您不想移驾,我给你移来: http://blog.csdn.net/colder2008/artic ...

  3. Linux - IDA - 安装 ( 带F5功能 )

    Linux - IDA - 安装 ( 带F5功能 ) 0x00 前言 最近在熟悉deepin系统,想着把逆向的一些软件也迁移过去,但像ida,Ollydbg这些工具一般都是在windows下使用,所以 ...

  4. LeetCode & Q169-Majority Element-Easy

    Array Divide and Conquer Bit Manipulation Description: Given an array of size n, find the majority e ...

  5. c 存储类型

    1,c语言中的存储类型(定义变量和函数的可见范围和生命周期)这些说明符放置在它们所修饰的类型之前.下面列出 C 程序中可用的存储类: auto register static extern 2,aut ...

  6. Python内置函数(26)——enumerate

    英文文档: enumerate(iterable, start=0) Return an enumerate object. iterable must be a sequence, an itera ...

  7. [UWP] Custom Capability的使用

    Custom Capability 是uwp开发中普通开发者较为不常用的内容,但是在一些OEM和驱动厂商,使用频率比较高 Custom Capability 有两种用户: 1.普通应用程序开发者: 2 ...

  8. spring boot定制Jackson ObjectMapper,为什么不生效

    先说结论: 项目中定制了spring 的redisTemplate,而这个template没有使用我自定义的Jackson ObjectMapper.所以不生效. 下面是详细过程: 起因是spring ...

  9. LinkedHashMap就这么简单【源码剖析】

    前言 声明,本文用得是jdk1.8 前面已经讲了Collection的总览和剖析List集合以及散列表.Map集合.红黑树还有HashMap基础了: Collection总览 List集合就这么简单[ ...

  10. C#使用Socket实现一个socket服务器与多个socket客户端通信

    在分布式调度系统中,如果要实现调度服务器与多台计算节点服务器之间通信,采用socket来实现是一种实现方式,当然我们也可以通过数据存储任务,子节点来完成任务,但是往往使用数据作为任务存储都需要定制开发 ...