【Henu ACM Round#15 D】Ilya and Escalator
2024-08-24 08:18:57
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
概率DP;
设f[i][j]表示前i个单位时间,j个人进入房间的概率是多少
然后想一下和i-1秒的时候要怎么转移就可以了。
i-1秒可能进入了一个人->f[i][j]+=f[i-1][j-1]*p
i-1秒没有人进去->
①已经有n个人了,f[i][j] += f[i-1][j]
②还没有n个人(j
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 2000+10;
double f[N][N];
//f[i][j]��ʾǰi��,j���˽�ȥ�ĸ���
int n;double p;int t;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
#ifdef LOCAL_DEFINE
freopen("rush.txt","r",stdin);
#endif
cin >> n >> p >> t;
f[0][0] = 1;
for (int i = 1;i <= t;i++)
for (int j = 0;j <= n;j++){
if (j==n){
f[i][j] += f[i-1][j];
}else
f[i][j] += f[i-1][j]*(1-p);
if (j>0){
f[i][j] += f[i-1][j-1]*p;
}
}
double ans = 0;
for (int i = 0;i <= n;i++){
ans+=f[t][i]*i;
}
cout <<fixed<<setprecision(10)<< ans << endl;
return 0;
}
最新文章
- css基础
- Linux RAID卡优化
- Delphi与Windows 7下的用户账户控制(UAC)机制 及 禁用兼容性助手
- AngularJs的UI组件ui-Bootstrap分享(十二)——Rating
- MVC 之 Partial View 用法
- Codeforces 445 A DZY Loves Chessboard【DFS】
- 【转】Monkeyrunner测试1——Monkeyrunner的使用
- [AngularJS + RxJS] Search with RxJS
- JDBC开发
- js中对象的自定义排序
- 【LR9】【LOJ561】CommonAnts 的调和数 数论 筛法
- List集合三种遍历方法
- ASP.NET MVC5使用Area区域
- ROSETTA使用技巧随笔--RosettaLigand Docking
- XML报错:The reference to entity ";characterEncoding"; must end with the &#39;;&#39; delimite
- 【RabbitMQ】——5种队列(转)
- python中装饰器使用
- laravel 单词
- web api 权限控制
- ruby on rails 权限管理gem cancan
热门文章
- 【HDU-4614】Vases and Flowers(线段树双查询)
- JavaScript编程随笔
- 面试题:Student s = new Student();在内存中做了哪些事情?即创建一个对象做了哪些事情
- C#重构经典全面汇总
- hibernate动态表名映射--仅仅有想不到,没有做不到
- 51Nod 不重叠的线段(贪心)
- php八大设计模式之策略模式
- appium使用教程(一 环境搭建)-------------2.安装部署
- iOS开发—— UIMenuController的使用
- django 在非空的字段里插入现象表述