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