[概率dp] hdu 4336 Card Collector
来源:互联网 发布:淘宝充流量要验证码 编辑:程序博客网 时间:2024/05/22 03:17
代码
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<map>#include<algorithm>using namespace std;const double eps=1e-9;const int maxn=20;const int maxs=(1<<maxn)+5;double p[maxn],dp[maxs];int num[maxs]={0};int n;int main(){ for(int i=0;i<(1<<20);i++) { int x=i; while(x>0) { num[i]+=(x&1); x>>=1; } } while(cin>>n) { p[0]=1; for(int i=1;i<=n;i++) scanf("%lf",&p[i]),p[0]-=p[i]; dp[(1<<n)-1]=0; for(int len=n-1;len>=0;len--) { for(int s=0;s<(1<<n);s++) { if(num[s]!=len) continue; double x=p[0],y=1.0; for(int dig=0;dig<n;dig++) if((s>>dig)&1) x+=p[dig+1]; else y+=p[dig+1]*dp[(s^(1<<dig))]; x=1-x; if(fabs(x)<eps) {dp[s]=0;continue;} dp[s]=y/x; } } printf("%.9f\n",dp[0]); } return 0;}
0 0
- hdu 4336 Card Collector(概率DP)
- hdu 4336 Card Collector (概率dp)
- 概率dp HDU 4336 Card Collector
- hdu-4336-Card Collector-概率DP
- HDU - 4336 Card Collector(概率dp)
- HDU 4336 Card Collector 状压+概率dp
- 概率dp HDU 4336 Card Collector
- HDU 4336 Card Collector (状压+概率DP)
- HDU 4336 Card Collector(概率DP)
- HDU 4336 Card Collector [概率DP]
- [概率dp] hdu 4336 Card Collector
- HDU 4336 Card Collector (概率dp)
- hdu 4336 Card Collector 概率DP 状态压缩DP
- HDU 4336 Card Collector(状态压缩dp+概率dp)
- hdu - 4336 - Card Collector - 容斥 || 概率dp
- HDU 4336 Card Collector 状态压缩+概率DP
- HDU 4336 Card Collector(动态规划-概率DP)
- HDU 4336 Card Collector(状压枚举+概率dp)
- linux学习10:工作管理与进程管理
- python3使用sax操作xml
- pat 1110. Complete Binary Tree (25)
- 链表之逆序建表
- javascript实现获取指定精度的上传文件的大小
- [概率dp] hdu 4336 Card Collector
- python 集合操作符和关系符号
- Telegram 之 MTProtoKit 架构分析
- 吉他调弦
- A - Wolf and Rabbit
- 数据库设计原则(转载)
- Binder学习指南
- 安装MongoDB
- Spring+Mybatis+Tomcat下多数据源与 atomikos 分布式事务配置