通过最后的概率求最终的期望

#include<bits/stdc++.h>
using namespace std; const int maxn = ; double p,dp[maxn][maxn]; int n,t; int main(){
cin>>n>>p>>t;
dp[][n]=;
for(int i=;i<=t;i++){
dp[i][]=dp[i-][]+dp[i-][]*p;
for(int j=;j<=n;j++)
dp[i][j]=dp[i-][j]*(-p)+dp[i-][j+]*p;
}
double ans=;
for(int i=;i<=n;i++)
ans+=1.0*dp[t][i]*(n-i);
printf("%.10lf\n",ans);
}

最新文章

  1. 1Z0-053 争议题目解析702
  2. ASP.NET MVC 实现AJAX跨域请求方法《1》
  3. AMD加载器实现笔记(四)
  4. SSRS 的简单使用(二)
  5. Linux时间函数之gettimeofday()函数之使用方法
  6. 解惑好文:移动端H5页面高清多屏适配方案 (转)
  7. LightOJ 1313 - Protect the Mines(凸包)
  8. jquery树形菜单完整代码
  9. JS学习第二课
  10. Support Library官方教程(2)各支援包的特性详介(含表)*
  11. Cocos2d-x 3.x 资料整理
  12. BZOJ 1237 配对
  13. Building,Packaging,Deploying,and Administering Applications and Types
  14. Linux下hp打印机驱动hplip分析
  15. [struts2学习笔记] 第三节 创建struts 2 HelloWorld所需的六个步骤
  16. GitHub最基本使用总结
  17. Android SharedPreferences增,删,查操作
  18. java.util.LinkedHashMap cannot be cast to xxx 和 net.sf.ezmorph.bean.MorphDynaBean cannot be cast to xxx
  19. Nginx防压力测试
  20. I/O dempo

热门文章

  1. SpringCloud广告系统随想
  2. Spring boot热部署实战
  3. Dart编程运算符
  4. FontFamily 和Font 的区别
  5. 笨办法学Python记录--习题15-17 开始读写文件啦
  6. 在 input 的 placeholder中 使用iconfont
  7. 带你走进webpack世界,成为webpack头号玩家。
  8. Android中滑屏实现----触摸滑屏以及Scroller类详解 .
  9. D语言简介
  10. 5.1_springboot2.x与安全(spring security)