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 |
Re:哪位同仁给找一下错,(WA),是否是精度问题啊???In Reply To:哪位同仁给找一下错,(WA),是否是精度问题啊??? Posted by:zhenly at 2006-09-30 12:02:32 > #include<stdio.h> > int c(m,n); > void main() > { > int n,m,i; > int rank[50001]; > int aver,b;double u; > scanf("%d%d",&n,&m); > while(n!=0&&m!=0) > { > aver=0; > for(i=1;i<=n;i++) > scanf("%d",&rank[i]); > u=(double)c(m,n); > b=1; > aver=(rank[m]-rank[n-m+1])*b; > for(i=m+1;i<=n;i++) > { > b=b*(i-1)/(i-m); > aver+=(rank[i]-rank[n-i+1])*b; > } > printf("%.3f\n",aver/u); > scanf("%d%d",&n,&m); > } > } > int c(m,n) > { > int i,rel=1; > if(m>n) > return 0; > else if(m==n) > return 1; > else > { > for(i=n;i>=n-m+1;i--) > { > rel*=i; > } > for(i=1;i<=m;i++) > rel/=i; > return rel; > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator