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 |
谁能告诉我错哪了。。。#include<stdio.h> #include<string.h> #define N 105 double a[1005][N]; int main() { int i,j,n,m,s,p; double c,add,num; while(scanf("%lf",&c),c) { scanf("%d%d",&n,&m); if(m>c||m>n) { printf("0.000\n"); continue; } if(n>1000) { if(n%2==1) n=1001; else n=1000; } for(i=0;i<=n;i++) for(j=0;j<=(int)c;j++) a[i][j]=0; a[1][1]=1; add=1/c; for(i=1;i<n;i++) { for(j=0;j<=(int)c;j++) { // printf("%d----i\n%d-----j\n",i,j); if(j==0) { a[i+1][1]+=a[i][j]; } else { a[i+1][j+1]+=a[i][j]*add*(c-(double)j); num=a[i][j]*add*j; a[i+1][j-1]+=num; } } } printf("%.3lf\n",a[n][m]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator