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

http://codeforces.com/problemset/problem/518/D 题意:n个人,每秒有p的概率进电梯,求t秒后电梯里人数的期望 考虑dp:f[i][j]代表第i秒有j个人的概率,f[0][0]=1,f[i][j]=f[i-1][j-1]*p+f[i-1][j]*(1-p),特别有:f[i][n]=f[i-1][n]+f[i-1][n-1]*p #include<cstdio> #include<cmath> #include<algorithm&g…
题链: 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]…
题意:给定 n 个人,在每一时刻一个人进入地铁的概率是 p,站着不动的概率是 1-p,然后问你 t 时间地铁里有多少人. 析:很明显这是一个期望DP,用d[i][j]表示 i 时刻 j 个人进入地铁的概率,有两种情况,要么第 i-1 时刻已经有 j 个人了,那么就不进,要么第 i-1 时刻只有 j-1个人,就得进入, 也就是d[i][j] = d[i-1][j] * (1-P) + d[i-1][j-1] * p;这就是状态转移方程,最重要的是有一种情况一定要注意...那就是当第 i-1 时刻已…
D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine…
D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine…
CF518D. Ilya and Escalator 题意:n个人,每秒p的概念队首的人进入电梯,求t秒后期望人数 直接使用期望定义 \(f[i][j]\) i秒后电梯中j个人的概率 注意n个人的时候直接\(f[i][n] \rightarrow f[i+1][n]\) #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmat…
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 tw…
Ilya and Matrix Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 313C Description Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matri…
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…
Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number written on vertex i is equal to ai. Ily…