标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3407 Accepted Submission(s): 1665
Special Judge
#include<bits/stdc++.h> using namespace std; const int maxn=1<<21; double dp[maxn]; double p[21]; int main(){ int n; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++) scanf("%lf",&p[i]); dp[(1<<n)-1]=0; for(int s=(1<<n)-2;s>=0;s--){ double sum=1.0,sump=0; for(int j=0;j<n;j++){ if(!((1<<j)&s)){ sum+=dp[s|(1<<j)]*p[j]; sump+=p[j]; } } dp[s]=sum/sump; } cout<<dp[0]<<"++++"<<endl; printf("%.5f\n",dp[0]); } return 0; }
HDU 4336——Card Collector——————【概率dp】
标签:
原文地址:http://www.cnblogs.com/chengsheng/p/4782845.html