| ||||||||||
| 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了快20次了...#include <stdio.h>
#include <math.h>
#include <algorithm>
int n;
double p;
int x[20];
double ans[20];
int main()
{
while (scanf("%d %lf",&n,&p)!=EOF)
{
for (int i=0;i<n;i++) scanf("%d",&x[i]);
std::sort(x,x+n);
ans[0]=(pow(p-1,x[0]-1)-1.0)/(p-2);
for (int i=1;i<n;i++)
ans[i]=ans[i-1]*(1-p)*(pow(p-1,x[i]-x[i-1]-1)-1.0)/(p-2);
double e=ans[n-1]*(1-p);
printf("%.7lf\n",fabs(e));
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator