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

泪奔,向大神求助啊,为何WA啊..

Posted by alizard at 2011-07-18 19:35:11 on Problem 2651
#include "stdio.h"
#include "math.h"

main()
{
    int n,i;
    double p,t,jf,a,b,fx[40];
    scanf("%d%lf",&n,&p);
    while(n!=0)
    {
        fx[0]=pow(2,n);
        for(i=1;i<=n;i++)
        {
            a=pow(2,n-i);
            b=a/fx[i-1];
            fx[i]=1/(1-p);
            if(b>p)
                fx[i]*=(b-p)*a+(1-b)*(a+fx[i-1])/2;
            else
                fx[i]*=(1-p)/2*((fx[i-1]-a)/(1-b)*(p-b)+a+fx[i-1]);
        }
        printf("%.3lf\n",fx[n]);
        scanf("%d%lf",&n,&p);
    }
}

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