【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

概率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;
}

最新文章

  1. css基础
  2. Linux RAID卡优化
  3. Delphi与Windows 7下的用户账户控制(UAC)机制 及 禁用兼容性助手
  4. AngularJs的UI组件ui-Bootstrap分享(十二)——Rating
  5. MVC 之 Partial View 用法
  6. Codeforces 445 A DZY Loves Chessboard【DFS】
  7. 【转】Monkeyrunner测试1——Monkeyrunner的使用
  8. [AngularJS + RxJS] Search with RxJS
  9. JDBC开发
  10. js中对象的自定义排序
  11. 【LR9】【LOJ561】CommonAnts 的调和数 数论 筛法
  12. List集合三种遍历方法
  13. ASP.NET MVC5使用Area区域
  14. ROSETTA使用技巧随笔--RosettaLigand Docking
  15. XML报错:The reference to entity &quot;characterEncoding&quot; must end with the &#39;;&#39; delimite
  16. 【RabbitMQ】——5种队列(转)
  17. python中装饰器使用
  18. laravel 单词
  19. web api 权限控制
  20. ruby on rails 权限管理gem cancan

热门文章

  1. 【HDU-4614】Vases and Flowers(线段树双查询)
  2. JavaScript编程随笔
  3. 面试题:Student s = new Student();在内存中做了哪些事情?即创建一个对象做了哪些事情
  4. C#重构经典全面汇总
  5. hibernate动态表名映射--仅仅有想不到,没有做不到
  6. 51Nod 不重叠的线段(贪心)
  7. php八大设计模式之策略模式
  8. appium使用教程(一 环境搭建)-------------2.安装部署
  9. iOS开发—— UIMenuController的使用
  10. django 在非空的字段里插入现象表述