| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
泪奔,向大神求助啊,为何WA啊..#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator