Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我表示很蛋疼

Posted by lisency at 2012-04-28 20:49:12 on Problem 3557
http://www.cppblog.com/Yuan/archive/2010/09/02/125640.html?opt=admin

最终在这里找到答案,水过了
#include<cstdio>
#include<cmath>

double dp[30];
int C[30][30];

void init()
{
    for(int i=0;i<30;i++)
        C[i][0]=C[i][i]=1;
    for(int i=2;i<30;i++)
        for(int j=1;j<i;j++)
            C[i][j]=C[i-1][j]+C[i-1][j-1];
}

int main()
{
    init();
    int n;
    double p;
    while(~scanf("%d%lf",&n,&p))
    {
        dp[1]=1.0;
        //_dp[n] = ∑C[n-1,k-1]*dp[k]*(1-p)^(k*(n-k))
        //dp[n]=1-_dp[n];
        for(int nn=2;nn<=n;nn++)
        {
            double ans = 0.0;
            for(int k=1;k<nn;k++)
                ans+=C[nn-1][k-1]*dp[k]*pow(1-p,k*(nn-k)+0.0);
            dp[nn]=1-ans;
        }
        printf("%.8f\n",dp[n]);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator